Array.some() and Array.every() do pretty much what you'll expect as well. .some() loops over an array and checks if one or more values according to the conditions setup. .every() does the same but returns a true or false if every value in the array checks out.
const heroes = [
{
name: 'Black Widow',
superHero: true,
team: 'Avengers'
},
{
name: 'Thor',
superHero: true,
team: 'Avengers'
},
{
name: 'Captain America',
superHero: true,
team: 'Avengers'
},
{
name: 'Mr. Bean',
superHero: false,
team: 'Great-Britain'
},
{
name: 'Batman',
superHero: true,
team: 'Justice League'
},
]
// Do we have a hero in the array?
const heroesPresent = heroes.some(hero => hero.superHero === true);
console.log(heroesPresent);
// Are all these people heroes?
const allHeroes = heroes.every(hero => hero.superHero === true);
console.log(allHeroes);