Last active
May 25, 2017 22:06
-
-
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]
This file contains hidden or 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 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