Use Destructuring Assignment to Assign Variables from Objects challenge

Use Destructuring Assignment to Assign Variables from Objects challenge
0

#1

Tell us what’s happening:

Hello, I need help to pass this challenge.

Your code so far


function getLength(str) {
  "use strict";

  // change code below this line
  var 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'));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 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


#2

#3

First of all, only change the following original line. Do not add anything above this line or below this line.

const length = 0; // change this

Second, see if the following template helps you to better understand how to write the syntax:

const {objPropName: newVariableName} = objName;

#4

Thank you so much, I undertand now.