Using Array.every() to Test All Elements in Javascript


Check if all elements in an array pass a test.

Source Code

let ages = [22, 19, 24, 25];
let allAdults = ages.every(function(age) {
  return age >= 18;
});
console.log(allAdults); // true
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments