function getLength(str) {
"use strict";
// change code below this line
var length = {x:12};
const {x: len} = length ; // 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.
the value on the left of the colon has to be a valid property of the object you are destructuring.
and, the value on the right of the equal sign has to be the name of the object
In this case str is the object we want to destructure. We want to pull out the ‘length’ property and give it a new name ‘len’.
So re-read the example given on how to do that and hopefully with the additional information I just gave you, you can figure out how to solve this.
You still don’t seem to understand the example or my response.
You’ve put ‘length’ on the right side of the equal sign. Is ‘length’ the name of the object you are destructuring?
You’ve also put ‘str’ on the left of the colon : , is ‘str’ the name of a property found in the object you are destructuring?
You’ll need to pay attention to what is used on each side of the colon and each side of the equal sign. Where does the object name go? Where does the property go? Where does the new name go?
When you understand this (by either reading the above response or looking at the example given) you’ll get this one right.
You must use the function var parameter and not the global var. Example:
var length = {x:12};
function getLength(str) {
"use strict";
// change code below this line
const {x: len} = str ; // Use **str**, not use **length**
// change code above this line
return len; // you must assign length to len in line
}
console.log(getLength(length));