.every() Method
Use the .every()
method if you want to check if every element in the array passes a condition. In this example, we'll check to make sure that everyone that has registered is above the age of 18.
Our output was false
. The fourth element in our array is 16, which is obviously not greater than 18. As a result the entire array is false. If you got rid of 16, the array would return true. Because our function is element > 18
an element with a value of exactly 18 would not work either.
Last updated