ES6: Destructuring Objects I

Published by Isaac Pak in

In JavaScript, you can do basic object assignment like this:

const obj =  { one : 1, two : 2 }

let one = obj.one
let two = obj.two

However, with ES6 you can assign the variables in a much more succinct way. Use ES6 object destructuring to assign variables one and two to obj.one and obj.two respectively.

Although you can use let, var, or const for assignment, DO NOT use these in this challenge.

Notes

  • Ignore the backticks `` (used for validation).
  • Ignore the .toString() function (used for validation).
  • Replace the commented part of the first line with proper, left-side part of the solution.
  • If you know how to use object destructuring, go ahead and complete the challenge, otherwise check the Resources tab for examples and then come back to try the challenge.
Watch a quick demo on how Edabit works.