-
-
Save pleabargain/f8e9eb694b0e5efcf3957ad5c92e5f24 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