DEV Community

loading...

Discussion on: JavaScript Array.flatMap()

Collapse
patrickradulian profile image
Patrick Radulian

Very nice summary!

You may want to correct one passage though:

// Step 1: created a 2-level deep array
const twoLevelDeep = names.flatMap((name, index) => [ [name, index] ]);
// [ [ ['jane', 1] ] ]

In this step, you actually use .map and not .flatMap

Cheers!

Collapse
samanthaming profile image
Samantha Ming Author

thank you for the catch!!! will fix it right now 😱