From the course: Learning Functional Programming with JavaScript (ES5)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Every/some

Every/some - JavaScript Tutorial

From the course: Learning Functional Programming with JavaScript (ES5)

Start my 1-month free trial

Every/some

- [Narrator] We now move onto two functions that behave very similarly to each other. These functions are called some and every. Some and every are similar to filter but instead of giving us an array's output, they simply return true or false, some returns true if the function we give it returns true for at least one of the elements in the array, every returns true only if the function we give it returns true for all of the elements in the array and false otherwise. So for example, if we have an array of all even numbers and we pass that into every along with a function that checks if each element is even, every would return true because all of the elements are even. If we pass this array into some with the same criteria, it will return true also because at least one of the elements is even. If we change one of the elements in our array so that it's odd and then pass it into every, every now returns false since all of the elements are not even, however if we pass this same array into…

Contents