Test all elements in an array

The every method checks all elements in an array against a given function and only returns true if every element in the array also returns true for that function. It will return false if the passed function returns false for even just one of the elements. It does not test empty elements and leaves the original array unchanged.


const pizzas = [
  { name: 'Extra hot', ingredients: ['Pepperoni', 'Cheese'], isHot: false },
  { name: 'Hawaii', ingredients: ['Pineapple', 'Cheese'], isHot: true },
  { name: 'Medium hot', ingredients: ['Pepperoni', 'Cheese'], isHot: true },

const hotPizzasOnly = pizzas.every(pizza => {return pizza.isHot}); // false because one element returns false