Guest User

Untitled

a guest
Jul 16th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. const masterArray = [1,2,3,4,5,6];
  2. const candidateArray = [2,5,6];
  3.  
  4. //Test for subset.
  5.  
  6. //create a set from the two.
  7. const s1 = new Set(masterArray.concat(candidateArray));
  8.  
  9. //Compare the sizes of the master array and the created set
  10. //If the sizes are same, no new elements are added that means
  11. //the candidate is complete subset.
  12. s1.size === masterArray.length;
Add Comment
Please, Sign In to add comment