Skip to main content

JavaScript Array some and every — exercises and bug fixes

5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Array some and every 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

    Check for any match

    easy10 min

    Use some to check whether any number is above five.

  2. 2

    Check they all match

    easy10 min

    Use every to check whether all numbers are above five.

  3. 3

    Validate a form

    easy10 min

    Check that every field has been filled in.

  4. 4

    Look for a problem

    easy10 min

    Check whether any score is below fifty.

  5. 5

    Test an empty array

    medium10 min

    Show what every gives back for an empty array.

Find the bug(5)

  1. 1

    Fix every used instead of some

    easy8 min

    Only one match is needed, not all of them.

  2. 2

    Fix some used for validation

    easy8 min

    All fields must be filled, not just one of them.

  3. 3

    Fix the missing return

    easy8 min

    Without a return the callback is always undefined, which is falsy.

  4. 4

    Fix filter used for a yes or no

    easy8 min

    A boolean is wanted, not a list of matches.

  5. 5

    Fix the inverted active check

    easy8 min

    The question is whether all users are active, not whether any are.

Ready to write the code?

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

Open the workspace