How can I check if a string ends with a particular character in JavaScript?
Example: I have a string
var str = \"mystring#\";
I wa
So many things for such a small problem, just use this Regular Expression
var str = "mystring#"; var regex = /^.*#$/ if (regex.test(str)){ //if it has a trailing '#' }