← Back to challenges

ES6: Destructuring Objects I

JavaScriptHardlanguage_fundamentalsobjects

Instructions

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.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Find the Largest Number in an Array