Skip to content

Instantly share code, notes, and snippets.

@rurtubia
Created December 19, 2015 15:45
Show Gist options
  • Save rurtubia/03e71cad244cb130f75f to your computer and use it in GitHub Desktop.
Save rurtubia/03e71cad244cb130f75f to your computer and use it in GitHub Desktop.
My solution to the 9th bonfire at FreeCodeCamp
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