Created
January 6, 2018 01:03
-
-
Save WonderDev21/4ac851f45d946911d509a451c004e553 to your computer and use it in GitHub Desktop.
Yuki's Answer1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isSubset (array1, array2) { | |
var temp = []; | |
array1 = array1.toString().split(',').map(Number); | |
array2 = array2.toString().split(',').map(Number); | |
for(i in array2) { | |
if(array1.indexOf(array2[i]) === -1) temp.push(array2[i]); | |
} | |
if(temp.length>0) return false; | |
else return true; | |
} | |
console.log(isSubset([1,2,3,4,5], [2,3,1]));///true | |
console.log(isSubset([1,2,3,4,5], [2,3,9]));///false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment