Created
September 18, 2016 12:06
-
-
Save jgresalfi/ae378e5d5068160724c44980ac876bc8 to your computer and use it in GitHub Desktop.
Verify that all characters in second array element are contained in first element.
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 mutation(arr) { | |
var str1 = arr.slice(0, 1).join(" ").toLowerCase(), | |
str2 = arr.slice(1).join(" ").toLowerCase(), | |
hits = 0; | |
for (var i = 0; i < str2.length; i++) { | |
if (str1.indexOf(str2[i]) !== -1) { | |
hits += 1; | |
} | |
} | |
if (hits === str2.length) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
mutation(["Alien", "line"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment