Last active
April 2, 2018 16:51
-
-
Save 19h47/4caacab6cc72f6af12a9674feafb5285 to your computer and use it in GitHub Desktop.
Check if a string ends with a given string target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Confirm endings | |
* | |
* Check if a string ends with a given target | |
* | |
* @param String string | |
* @param String target A target to match with the given string | |
*/ | |
function confirmEnding(string, target) { | |
return string.substr(-target.length) === target ? true : false; | |
} | |
// Used | |
confirmEnding("Bastian", "n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment