JavaScript String Escape Characters — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript String Escape Characters 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
Escape a quote
easy10 minPut double quotes inside a double-quoted string.
- 2
Add a new line
easy10 minReport how many lines the escaped text holds.
- 3
Write a backslash
easy10 minBuild a Windows path and report it.
- 4
Avoid the escape
easy10 minUse single quotes so the apostrophe needs no backslash.
- 5
Count an escaped character
medium10 minReport the length of a string holding one newline.
Find the bug(5)
- 1
Fix the unescaped quote
easy8 minThe inner quotes end the string early.
- 2
Fix the single backslash
easy8 minOne backslash escapes the next character instead of appearing.
- 3
Fix the literal n
easy8 minA newline needs a backslash before the n.
- 4
Fix the tab written as spaces
easy8 minUse a real tab escape rather than typing spaces.
- 5
Fix the escape counted twice
easy8 minAn escaped newline is a single character.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace