Use Destructuring Assignment to Assign Variables from Objects


#1

Tell us what’s happening:

Your code so far


function getLength(str) {
  "use strict";

  // 在这行以下修改代码
  const length = {x:str.length}; // change this
  // 在这行以上修改代码
   const {x:len}=length;
  return len; // 你必须在这行将 length 赋值给 len

}

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/79.0.3945.79 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.one/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-objects/