Created
December 19, 2015 15:45
-
-
Save rurtubia/03e71cad244cb130f75f to your computer and use it in GitHub Desktop.
My solution to the 9th bonfire at FreeCodeCamp
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 end(str, target) { | |
// "Never give up and good luck will find you." | |
// -- Falcor | |
//obtain the number of characters from str that will be compared | |
subLength = target.length; | |
//gets the substring from the end of str | |
//'-' operator is used to get a substring from the end of the original string | |
sub = str.substr(-subLength); | |
//compares the substring to the target string | |
if(sub == target) | |
return true; | |
else | |
return false; | |
} | |
end("Bastian", "an"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment