Skip to content

Instantly share code, notes, and snippets.

@shahidcodes
Created April 12, 2017 11:28
Show Gist options
  • Save shahidcodes/ba35582435a59a066fb40d20375a41b7 to your computer and use it in GitHub Desktop.
Save shahidcodes/ba35582435a59a066fb40d20375a41b7 to your computer and use it in GitHub Desktop.
FreeCodeCamp Javascript Algorithm | Confirm The Ending
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if(target.length == 1) return str.substr(-1) == target;
else{
boo = str.split(" ").reverse()[0].includes(target);
console.log( boo );
return boo;
}
}
confirmEnding("Bastian", "n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment