Skip to main content

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

    Escape a quote

    easy10 min

    Put double quotes inside a double-quoted string.

  2. 2

    Add a new line

    easy10 min

    Report how many lines the escaped text holds.

  3. 3

    Write a backslash

    easy10 min

    Build a Windows path and report it.

  4. 4

    Avoid the escape

    easy10 min

    Use single quotes so the apostrophe needs no backslash.

  5. 5

    Count an escaped character

    medium10 min

    Report the length of a string holding one newline.

Find the bug(5)

  1. 1

    Fix the unescaped quote

    easy8 min

    The inner quotes end the string early.

  2. 2

    Fix the single backslash

    easy8 min

    One backslash escapes the next character instead of appearing.

  3. 3

    Fix the literal n

    easy8 min

    A newline needs a backslash before the n.

  4. 4

    Fix the tab written as spaces

    easy8 min

    Use a real tab escape rather than typing spaces.

  5. 5

    Fix the escape counted twice

    easy8 min

    An 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