Skip to main content

JavaScript String Concatenation — exercises and bug fixes

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

    easy10 min

    Join the first and last name with a space.

  2. 2

    Add to a string

    easy10 min

    Build the text up with the plus-equals operator.

  3. 3

    Repeat a string

    easy10 min

    Repeat the pair of letters three times.

  4. 4

    Force the addition first

    easy10 min

    Use brackets so the numbers add before joining.

  5. 5

    Join an array

    medium10 min

    Use join rather than a loop to build the list.

Find the bug(5)

  1. 1

    Fix the missing space

    easy8 min

    The names have run together.

  2. 2

    Fix the numbers joined as text

    easy8 min

    Brackets are needed so the addition happens first.

  3. 3

    Fix the total started as text

    easy8 min

    Starting at an empty string joins the numbers instead of adding.

  4. 4

    Fix repeat used with join

    easy8 min

    repeat takes a count, not a separator.

  5. 5

    Fix the loop that leaves a separator

    easy8 min

    The trailing separator should not be there.

Ready to write the code?

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

Open the workspace