Use some to check whether any number is above five.
Acceptance criteria
- 1.#out should show true.
JavaScript Tutorial · JavaScript Arrays
These 10 tasks go with the JavaScript Array some and every chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “JavaScript some and every check whether elements pass a test and return true or false.” .
1.Check for any matchexercise · easy · 10 min
Use some to check whether any number is above five.
Passes when: #out should show true.
2.Check they all matchexercise · easy · 10 min · practice plan
Use every to check whether all numbers are above five.
Passes when: #out should show false.
3.Validate a formexercise · easy · 10 min · practice plan
Check that every field has been filled in.
Passes when: #out should show true.
4.Look for a problemexercise · easy · 10 min · practice plan
Check whether any score is below fifty.
Passes when: #out should show true.
5.Test an empty arrayexercise · medium · 10 min · practice plan
Show what every gives back for an empty array.
Passes when: #out should show true.
6.Fix every used instead of somebug fix · easy · 8 min
Only one match is needed, not all of them.
Passes when: #out should show true.
7.Fix some used for validationbug fix · easy · 8 min · practice plan
All fields must be filled, not just one of them.
Passes when: #out should show false.
8.Fix the missing returnbug fix · easy · 8 min · practice plan
Without a return the callback is always undefined, which is falsy.
Passes when: #out should show true.
9.Fix filter used for a yes or nobug fix · easy · 8 min · practice plan
A boolean is wanted, not a list of matches.
Passes when: #out should show true.
10.Fix the inverted active checkbug fix · easy · 8 min · practice plan
The question is whether all users are active, not whether any are.
Passes when: #out should show false.
Between them these tasks cover some, every and Validation.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.