Use Destructuring Assignment to Assign Variables from Objects looks correct but not passing test

Tell us what’s happening:
Hi guys. My console.log and bottom of screen show I reassigned but it won’t pass the last test. Am I doing something wrong?

Your code so far



console.log(getLength('FreeCodeCamp'));

function getLength(str) {
  "use strict";

  
  const length = {x:str.length};
  let {x:len} = length;
  console.log(len);
  
  return len;

}

console.log(getLength('FreeCodeCamp'));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 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/

You can do this in one line because you are using deconstruction.

Get rid of this line.

Then change let to const. In the object the left side grabs certain value in this case method .length, on the right is where left value is assigned to the const. This is counter-intuitive. Right hand side of = is your whatever that can be deconstructed from in this case string prototype.

I hope I made sense, here is the solution if you still don’t get it.

Summary

const {length:len} = str;

return len;

Thank you. I’ll try it.