1const myArray: number[] = [2, 4, 6, 8, 10, 12, 14, 16];
2const elements: number[] = [4, 8, 12, 16];
3
4function containsAll(arr: number[]) {
5 return (
6 arr.includes(elements[0]) &&
7 arr.includes(elements[1]) &&
8 arr.includes(elements[2]) &&
9 arr.includes(elements[3])
10 );
11}
12console.log(containsAll(myArray));
13
14or you could use the following line:
15
16function c2(arr: number[]) {
17 return elements.every((val: number) => arr.includes(val));
18}