Sprawdź, czy pierwsza tablica zawiera wszystkie elementy JavaScript

// Not Supported in IE 9-11
const arr1 = ['pizza', 'cola'];
const arr2 = ['pizza', 'cake', 'cola'];

const containsAll = arr1.every(element => {
  return arr2.includes(element);
});

console.log(containsAll); // true


// Supported in IE 9-11
const arr1 = ['pizza', 'cola'];
const arr2 = ['pizza', 'cake', 'cola']

const containsAll = arr1.every(element => {
  return arr2.indexOf(element) !== -1;
});

console.log(containsAll); // true
Coding Era