Tell us what’s happening:
ok, it works, but what is the principal difference between this solution and good old:
const len = str.length;
Your code so far
const {length:len} = str; // change this
function getLength(str) {
"use strict";
// change code below this line
const {length:len} = str; // change this
// change code above this line
return len; // you must assign length to len in line
}
console.log(getLength('FreeCodeCamp'));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects/