Created
November 18, 2015 21:51
-
-
Save ambergkim/9a3b198fe342087681ab to your computer and use it in GitHub Desktop.
Free Code Camp Bonfire: Mutations
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) { | |
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