Created
April 12, 2017 11:28
-
-
Save shahidcodes/ba35582435a59a066fb40d20375a41b7 to your computer and use it in GitHub Desktop.
FreeCodeCamp Javascript Algorithm | Confirm The Ending
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 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