Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbess1/8f706f09eb235165d185 to your computer and use it in GitHub Desktop.
Save dbess1/8f706f09eb235165d185 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/dbess1 's solution for Bonfire: Confirm the Ending
// Bonfire: Confirm the Ending
// Author: @dbess1
// Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function end(str, target) {
//I used a conditional to check if str (string) has the requested ending letter or word
//The target is the requested letter or word which is being called below
if(str.substr(-target.length) == target){
return true;
}
else if(str.substr(-1) !== target){ //return false if it's not the requested letter or word
return false;
}
}
//This function named end is being called with arguments for str and target
end("Bastian", "n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment