Skip to main content

JavaScript String split — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript String split 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

    Split on a comma

    easy10 min

    Split the list and report how many parts there are.

  2. 2

    Split into words

    easy10 min

    Report the last word of the sentence.

  3. 3

    Reverse the letters

    easy10 min

    Split into characters, reverse them, and join back.

  4. 4

    Join with a separator

    easy10 min

    Join the parts with dashes.

  5. 5

    Capitalise every word

    medium10 min

    Split, capitalise each word, then join back.

Find the bug(5)

  1. 1

    Fix the missing separator

    easy8 min

    Splitting with no separator gives one whole piece.

  2. 2

    Fix the wrong separator

    easy8 min

    The sentence is split on words, not commas.

  3. 3

    Fix the join that adds commas

    easy8 min

    The letters should be glued together with nothing between.

  4. 4

    Fix the array never joined

    easy8 min

    The result is still an array of words.

  5. 5

    Fix reverse used on the string

    easy8 min

    Only an array can be reversed, so split first.

Ready to write the code?

The editor, the automatic checks and the worked solutions open up with an account.

Open the workspace