How can I check if a string ends with a particular character in JavaScript?
Example: I have a string
var str = "mystring#";
I want to know if that string is ending with #. How can I check it?
Is there a
endsWith()method in JavaScript?One solution I have is take the length of the string and get the last character and check it.
Is this the best way or there is any other way?