Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const masterArray = [1,2,3,4,5,6];
- const candidateArray = [2,5,6];
- //Test for subset.
- //create a set from the two.
- const s1 = new Set(masterArray.concat(candidateArray));
- //Compare the sizes of the master array and the created set
- //If the sizes are same, no new elements are added that means
- //the candidate is complete subset.
- s1.size === masterArray.length;
Add Comment
Please, Sign In to add comment