Skip to content

Instantly share code, notes, and snippets.

@rodpoblete
Last active May 25, 2017 22:06
Show Gist options
  • Save rodpoblete/83c3404a42a6a9f1e412ef4c04325938 to your computer and use it in GitHub Desktop.
Save rodpoblete/83c3404a42a6a9f1e412ef4c04325938 to your computer and use it in GitHub Desktop.
Encontrar si palabra se encuentra al final de cadena de texto - FCC [248]
function confirmEnding(str, target) {
if (target === str.substr(str.length - target.length)) { // compara target con la cadena de texto, que la función substr le da como parametros de inicio y fin
return true;
} else {
return false;
}
}
confirmEnding("Open sesame", "same");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment