Skip to main content

JavaScript continue Statement — exercises and bug fixes

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

    Skip one number

    easy10 min

    Add 1 to 6 together but skip the number 4. Show the total.

  2. 2

    Skip the even numbers

    easy10 min

    Add only the odd numbers from 1 to 9. Show the total.

  3. 3

    Ignore the negatives

    easy10 min

    Add up only the numbers that are zero or above. Show the total.

  4. 4

    Count what you kept

    easy10 min

    Count how many names are not empty. Show the count.

  5. 5

    Build a string without spaces

    medium10 min

    Join the letters of "a b c" together, skipping the spaces.

Find the bug(5)

  1. 1

    Fix break used instead of continue

    easy8 min

    break ends the loop, so everything after 4 is lost.

  2. 2

    Fix the inverted condition

    easy8 min

    This skips the odd numbers when it should skip the even ones.

  3. 3

    Fix the continue placed too late

    easy8 min

    The value is added before the check, so nothing is skipped.

  4. 4

    Fix the counter that never runs

    easy8 min

    The counter sits after continue, so it is skipped every time.

  5. 5

    Fix the wrong value skipped

    easy8 min

    This skips 4 when it should skip 3.

Ready to write the code?

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

Open the workspace