![Check if all the elements in values are included in arr](https://javascriptsource.com/wp-content/uploads/2021/09/Check-if-all-the-elements-in-values-are-included-in-arr-702x526.jpg)
Use Array.prototype.every()
and Array.prototype.includes()
to check if all elements of values
are included in arr
.
const includesAll = (arr, values) => values.every(v => arr.includes(v));
// Examples
includesAll([1, 2, 3, 4], [1, 4]); // true
includesAll([1, 2, 3, 4], [1, 5]); // false