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 - JavaScript Tutorial
From the course: Learning Functional Programming with JavaScript ES6+
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
-
-
-
-
-
Basics of functional data manipulation3m 38s
-
(Locked)
The spread operator8m 6s
-
(Locked)
Using the map() function6m 29s
-
(Locked)
Using the filter() function5m 40s
-
(Locked)
Using the every() and some() functions9m 18s
-
(Locked)
Preventing mutation with the slice() function8m 45s
-
(Locked)
Using the sort() function6m 55s
-
(Locked)
Using the reduce() function6m 50s
-
(Locked)
Combining array functions6m 10s
-
(Locked)
Solution: Recreating the map() function3m 11s
-
-
-
-