endsWith
adds endsWith method to the prototype of String. Returns boolean
Source
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
Example
console.log("hi this ends with a dollar".endsWith('dollar')); //true