5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Array flat lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Flatten a nested array and join the result with commas.
Flatten an array nested two deep and show the length.
Use Infinity to flatten however deep the nesting goes.
Use flatMap to split each sentence into words and join with commas.
Flatten an array of groups and show the total number of people.
One level is not enough for an array nested two deep.
map leaves each result nested inside its own array.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceflat returns a new array; it does not change the original.
The nesting is deeper than the depth given.
The groups need flattening into one list of people.