is an array a subset of an array javascript code example
Example 1: javascript is array a subset of array
const PlayerOne = ['B', 'C', 'A', 'D'];
const PlayerTwo = ['D', 'C'];
const result = PlayerTwo.every(val => PlayerOne.includes(val));
console.log(result);
Example 2: javascript check if array is subset of another
let superSet = ['B', 'C', 'A', 'D'];
let subSet = ['D', 'C'];
let mixedSet = new Set([...superSet, ...subSet]);
let isSubset = mixedSet.size == superSet.length