Last active
December 3, 2018 08:16
-
-
Save OdearOgy/fdb8f7a8167b189dd96d8ae195eda743 to your computer and use it in GitHub Desktop.
refactored function
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 findChars(word, ...letters){ | |
let maxIndex; | |
if (word.match(/^$/)) { | |
return -1; | |
} | |
for(let i = 0; i<letters.length; i++){ | |
if(word.indexOf(letters[i]) != -1){ | |
maxIndex = word.indexOf(letters[i]); | |
break; | |
} | |
else { | |
maxIndex = -1; | |
} | |
} | |
return maxIndex; | |
} | |
findChars("", "h","2"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment