Skip to content

Instantly share code, notes, and snippets.

@OdearOgy
Last active December 3, 2018 08:16
Show Gist options
  • Save OdearOgy/fdb8f7a8167b189dd96d8ae195eda743 to your computer and use it in GitHub Desktop.
Save OdearOgy/fdb8f7a8167b189dd96d8ae195eda743 to your computer and use it in GitHub Desktop.
refactored function
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