From the course: Learning Functional Programming with JavaScript ES6+

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Using the every() and some() functions

Using the every() and some() functions

- [Instructor] All right, well, at this point we've talked about the map function and the filter function, so the next function that we're going to take a look at is actually two functions, and these are the every and some functions. Now these two functions are kind of similar to each other and they're also kind of similar to the filter function, but with every and some, what we want to do generally is take an array of some sort of data, right? Numbers, or strings, or objects, something like that. It can be anything. And we want to get a single true or false answer regarding whether the elements in the array match some sort of criteria. So to give you an idea of what this might look like, let's say that we have an array of all odd numbers, one, three, five, seven, and nine, and we want to know whether all of those numbers are odd. Well, in that case, what we would do is we would define a function called isOdd that tells us whether or not a single number is odd, and we would pass that…

Contents