Created
January 3, 2022 07:25
-
-
Save Sanchithasharma/1d9fabde5b5d53758ed1963b076470a5 to your computer and use it in GitHub Desktop.
Confirm the Ending: Check if a string (first argument, str) ends with the given target string (second argument, 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
function confirmEnding(str, target) { | |
let targetLength = target.length | |
let strLength = str.length | |
return target === str.substring(strLength - targetLength); | |
} | |
confirmEnding("Bastian", "n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment