I had no luck with a coincidence, but it worked:
If you have a line, "This is my line." and would like to see if this ends with a period, do the following:
var myString = "This is my string."; var stringCheck = "."; var foundIt = (myString.lastIndexOf(stringCheck) === myString.length - stringCheck.length) > 0; alert(foundIt);
You can change the stringCheck variable to any string for verification. It would be best to throw this into your own function as follows:
function DoesStringEndWith(myString, stringCheck) { var foundIt = (myString.lastIndexOf(stringCheck) === myString.length - stringCheck.length) > 0; return foundIt; }
theJerm Jul 03 2018-12-12T00: 00Z
source share