Answers for ".reduce flatten array"

0

.reduce flatten array

const nested = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
let flat = nested.reduce((acc, it) => [...acc, ...it], []);
console.log(flat) // flat is [1, 2, 3, 4, 5, 6, 7, 8, 9]
Posted by: Guest on October-17-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language