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
Check for any match
easy10 minUse some to check whether any number is above five.
- 2
Check they all match
easy10 minUse every to check whether all numbers are above five.
- 3
Validate a form
easy10 minCheck that every field has been filled in.
- 4
Look for a problem
easy10 minCheck whether any score is below fifty.
- 5
Test an empty array
medium10 minShow what every gives back for an empty array.
Find the bug(5)
- 1
Fix every used instead of some
easy8 minOnly one match is needed, not all of them.
- 2
Fix some used for validation
easy8 minAll fields must be filled, not just one of them.
- 3
Fix the missing return
easy8 minWithout a return the callback is always undefined, which is falsy.
- 4
Fix filter used for a yes or no
easy8 minA boolean is wanted, not a list of matches.
- 5
Fix the inverted active check
easy8 minThe 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