Using Array.some() to Test If Any Element Passes in Javascript


Check if at least one element in an array passes a test.

Source Code

let ages = [16, 19, 20, 14];
let anyAdults = ages.some(function(age) {
  return age >= 18;
});
console.log(anyAdults); // true
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments