Use Destructuring Assignment to Assign Variables from Objects - Not understanding

Use Destructuring Assignment to Assign Variables from Objects - Not understanding
0

#1

Tell us what’s happening:
I’m not understanding what I’m supposed to do here

Your code so far


function getLength(str) {
  "use strict";

  // change code below this line
  const length = str.length; // change this
  // change code above this line

  return len = length; // 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/67.0.3396.99 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

If instead you want to store the values of voxel.x into a, voxel.y into b, and voxel.z into c, you have that freedom as well.

The example says the above can be written as,

const { x : a, y : b, z : c } = voxel // a = 3.6, b = 7.4, c = 6.54

Now consider the voxel as the str and you need to get the length of str,
with

ex: voxel.x gives the value of x

So to find the length of str think what you have to do


#3

@aerocraker

To make it a bit simple you can think of the str as an object with a property length that you want to access.