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");