The lodash _.some collection method can be used to test to see if just one element of an array, or key of an object in general meets a given condition. There is another collection method known as _.every that works in a similar way to that of the _.some method but will only return true when all elements of a collection meet a given condition. In this post I will be going over some simple examples of both, as well as some ways of doing so with just plain old vanilla js as well.
The lodash some method is used to quickly find out if at least one element in a collection meets a given condition. To use it just call the _.some method followed by the collection that is to be tested, followed by a function that will be used to test potentially all elements in the collection for a certain condition.
So it is not ti hard to just use a while loop for example to loop over the contents of an array and check to see if one element in the array meets a certain condition of course.
It is not to hard to write a some method of my own. The Object.keys method can be used to get all publc keys of an Object in general. This can then be used as a way to loop over all they keys and call a given test function that will return true if an element meets the desired condition. Such a method will work just fine with most Arrays and Object collections in general.