Skip to content

Instantly share code, notes, and snippets.

@Sanchithasharma
Created January 3, 2022 07:25
Show Gist options
  • Save Sanchithasharma/1d9fabde5b5d53758ed1963b076470a5 to your computer and use it in GitHub Desktop.
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).
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