DEV Community

Discussion on: 7 Ways to Iterate Over Arrays and When to Use Each

Collapse
 
lexlohr profile image
Alex Lohr
let allEntrees = orders.reduce(
(accumulator, currentValue) => 
  [...accumulator, ...currentValue.entree],
  [] // you forgot this here
)
Enter fullscreen mode Exit fullscreen mode

FTFY

Collapse
 
christinecontreras profile image
Christine Contreras

Thanks so much for catching this! updated.

Thread Thread
 
icecoffee profile image
Atulit Anand

Collapse
 
icecoffee profile image
Atulit Anand • Edited

lol never thought about this one, I used Object.values() instead and a tiny bit of mod in the logic.