Skip to content

Instantly share code, notes, and snippets.

@piqueen314 piqueen314/gist5
Created Dec 11, 2015

Embed
What would you like to do?
Check if a string (first argument) ends with the given target string (second argument).
// Bonfire: Confirm the Ending
// Author: @piqueen314
// Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function end(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
lenStr=str.length;
lenTar=target.length;
if(str.substr(lenStr-lenTar,lenTar)==target)
{
return true;
}
return false;
}
end("Bastian", "n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.