Created
September 9, 2016 02:52
-
-
Save jgresalfi/3934d6286fec7b79ea01431c032b0378 to your computer and use it in GitHub Desktop.
Confirm the Ending...match arg2 string with end of arg1 string...or don't...
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) { | |
var fragCount = target.length, | |
chunk = str.substring(str.length - fragCount); | |
if (chunk === target) { | |
return true; | |
} else { return false; } | |
} | |
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
Or with a ternary: