Skip to content

Instantly share code, notes, and snippets.

@ambergkim
Created November 18, 2015 21:51
Show Gist options
  • Save ambergkim/9a3b198fe342087681ab to your computer and use it in GitHub Desktop.
Save ambergkim/9a3b198fe342087681ab 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