Skip to content

Instantly share code, notes, and snippets.

@jgresalfi
Created September 18, 2016 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgresalfi/ae378e5d5068160724c44980ac876bc8 to your computer and use it in GitHub Desktop.
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.
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