Skip to content

Instantly share code, notes, and snippets.

@platypusrex
Created October 15, 2015 15:27
Show Gist options
  • Save platypusrex/8a90c6dfbada4cfe161e to your computer and use it in GitHub Desktop.
Save platypusrex/8a90c6dfbada4cfe161e to your computer and use it in GitHub Desktop.
Javascript - Check if a string (first argument) ends with the given target string (second argument).
function end(str, target) {
return str.substr(str.length - target.length) === target ? true : false;
}
end('platypus', 's');
end('I\'m pretty sure this thing is on', 'on');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment