Skip to content

Instantly share code, notes, and snippets.

@bflannery
Created December 20, 2016 22:44
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 bflannery/1bcefed84e872446a245f92c4c928e97 to your computer and use it in GitHub Desktop.
Save bflannery/1bcefed84e872446a245f92c4c928e97 to your computer and use it in GitHub Desktop.
Confirm The Ending of a String
// Check if a string (first argument, str) ends with the given target string (second argument, target).
function confirmEnding(str, target) {
return str.substr(-target.length) === target;
}
console.log(confirmEnding("Bastian", "n"));
console.log(confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment