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
Split on a comma
easy10 minSplit the list and report how many parts there are.
- 2
Split into words
easy10 minReport the last word of the sentence.
- 3
Reverse the letters
easy10 minSplit into characters, reverse them, and join back.
- 4
Join with a separator
easy10 minJoin the parts with dashes.
- 5
Capitalise every word
medium10 minSplit, capitalise each word, then join back.
Find the bug(5)
- 1
Fix the missing separator
easy8 minSplitting with no separator gives one whole piece.
- 2
Fix the wrong separator
easy8 minThe sentence is split on words, not commas.
- 3
Fix the join that adds commas
easy8 minThe letters should be glued together with nothing between.
- 4
Fix the array never joined
easy8 minThe result is still an array of words.
- 5
Fix reverse used on the string
easy8 minOnly 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