← Back to challenges

ES6: Destructuring Objects X

JavaScriptHardlanguage_fundamentalsformattingobjects

Instructions

Given an array of user objects.

let names = []

let users = [
  { name: "John", email: "[email protected]" },
  { name: "Jason", email: "[email protected]" },
  { name: "Jeremy", email: "[email protected]" },
  { name: "Jacob", email: "[email protected]" }
]

for(/* add code inside these parenthesis only */) {
      names.push(name)
}

console.log(names) // should log ["John", "Jason", "Jeremy", "Jacob"]

Push the first names of all users in the names array.

Notes

  • You only have to change the "for...of" loop parameters.
  • Ignore the const str assignment. This is only used for validation purposes.
  • Check the MDN docs to find out more about object destructuring in "for...of" loops.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Solve a Linear Equation