How to Check if an array contains a value matching some criterias in Javascript
The some()
method tests if at least one element passes the test implemented by the provided function. It returns a Boolean value.
const contains = (arr, criteria) => arr.some((v) => criteria(v));
// contains([10, 20, 30], v => v > 25 ) === true

You like our Content? Follow us to stay up-to-date.