Files
30-seconds-of-code/snippets/includesAll.md
Isabelle Viktoria Maciohsek caa67e2a49 Update snippet descriptions
2020-10-20 23:02:01 +03:00

419 B

title, tags
title tags
includesAll array,beginner

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