JavaScript Array concat and join — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Array concat and join lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Join two arrays
easy10 minCombine two arrays with concat and show the result joined by commas.
- 2
Combine with spread
easy10 minCombine two arrays using spread instead of concat.
- 3
Choose a separator
easy10 minJoin a list of words using a space, the word and, and another space.
- 4
Glue letters together
easy10 minJoin an array of letters with no separator at all.
- 5
Join three arrays
medium10 minConcat three arrays in one call and show the total length.
Find the bug(5)
- 1
Fix concat that was thrown away
easy8 minconcat returns a new array; it does not change the original.
- 2
Fix the array pushed instead of joined
easy8 minPushing an array adds it as a single nested element.
- 3
Fix the wrong separator
easy8 minThe list should read as a sentence, not a comma list.
- 4
Fix join called without a separator
easy8 minThe default separator adds commas between the letters.
- 5
Fix the spread that was missed
easy8 minWithout spread the arrays end up nested instead of merged.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace