Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.