- Learning JavaScript Data Structures and Algorithms
- Loiane Groner
- 81字
- 2021-08-27 18:41:16
Iterating using the every method
The first method we will take a look at is the every method. The every method iterates each element of the array until the function returns false, as follows:
numbers.every(isEven);
In this case, our first element of the numbers array is the number 1. 1 is not a multiple of 2 (it is an odd number), so the isEven function will return false, and this will be the only time the function will be executed.