let everyRequestValid = true; for (const request of requests) { if (!isValid(request)) { everyRequestValid = false; break; } } if (everyRequestValid) { // do something }
let everyUserEligible = true; for (const user of users) { if (!isEligible(user)) { everyUserEligible = false; break; } } if (everyUserEligible) { // do something }
if (requests.every(isValid)) { // do something }
if (users.every(isEligible)) { // do something }
// Double each value in `ints` const doubled = ints.map(n => n * 2);
// Get only the even values in `ints` const evens = ints.filter(n => n % 2 === 0);