Skip to content

Instantly share code, notes, and snippets.

@pleabargain
Forked from ambergkim/FCCBonfire.js
Created February 18, 2017 11:58
Show Gist options
  • Save pleabargain/f8e9eb694b0e5efcf3957ad5c92e5f24 to your computer and use it in GitHub Desktop.
Save pleabargain/f8e9eb694b0e5efcf3957ad5c92e5f24 to your computer and use it in GitHub Desktop.
Free Code Camp Bonfire: Mutations
function mutation(arr) {
firstWord = arr[0].toLowerCase();
secondWord = arr[1].toLowerCase().slice('');
lettersFound = 0;
for(i=0; i<secondWord.length; i++){
indexSearch = secondWord[i];
indexSearchResult = firstWord.indexOf(indexSearch, 0);
if(indexSearchResult == -1) {
return false;
} else {
lettersFound++;
}
}
if (lettersFound>0) {
return true;
}
}
mutation(["hello", "hey"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment