Skip to main content

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. 1

    Join two arrays

    easy10 min

    Combine two arrays with concat and show the result joined by commas.

  2. 2

    Combine with spread

    easy10 min

    Combine two arrays using spread instead of concat.

  3. 3

    Choose a separator

    easy10 min

    Join a list of words using a space, the word and, and another space.

  4. 4

    Glue letters together

    easy10 min

    Join an array of letters with no separator at all.

  5. 5

    Join three arrays

    medium10 min

    Concat three arrays in one call and show the total length.

Find the bug(5)

  1. 1

    Fix concat that was thrown away

    easy8 min

    concat returns a new array; it does not change the original.

  2. 2

    Fix the array pushed instead of joined

    easy8 min

    Pushing an array adds it as a single nested element.

  3. 3

    Fix the wrong separator

    easy8 min

    The list should read as a sentence, not a comma list.

  4. 4

    Fix join called without a separator

    easy8 min

    The default separator adds commas between the letters.

  5. 5

    Fix the spread that was missed

    easy8 min

    Without 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