https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects
This doesn’t work!!! why???
function getLength(str) {
"use strict";
// change code below this line
const length = str.length; // change this
const len = {len:length};
// change code above this line
return len; // you must assign length to len in line
}
console.log(getLength(‘FreeCodeCamp’));
const { x : a, y : b, z : c } = voxel // a = 3.6, b = 7.4, c = 6.54
You may read it as “get the field x and copy the value into a,” and so on.
Thanks @camperextraordinaire
???is this right then?.this is also not working!
function getLength(str) {
“use strict”;
// change code below this line
const length = {x:str.length}; // change this
const { x:len } = length;
// change code above this line
return len; // you must assign length to len in line
}
console.log(getLength(‘FreeCodeCamp’));
thank you so much @camperextraordinaire. I got it.
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’));