Files
30-seconds-of-code/snippets/js/s/array-includes-all-values.md
Angelos Chalaris 9d032ce05e Rename js snippets
2023-05-19 20:23:47 +03:00

526 B

title, type, language, tags, cover, dateModified
title type language tags cover dateModified
Check if array includes all values snippet javascript
array
tomatoes 2020-10-20T23:02:01+03:00

Checks if all the elements in values are included in arr.

  • 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));
includesAll([1, 2, 3, 4], [1, 4]); // true
includesAll([1, 2, 3, 4], [1, 5]); // false