How would I check whether a string contains the √ symbol?
var string = '√ foobar'
if (string.indexOf("f") > -1) { alert(string); }
Searching for "f", this finds the "f" in "foobar" fine. For what it's worth, the √ character does show as √ in the alert though:
var string = '√ foobar'
if (string.indexOf("√") > -1) { alert(string); }
Searching for "√" doesn't do anything, no alert message.
It works for me
var string = '√ foobar'
if (string.indexOf("√") > -1) {
alert(string);
}
But maybe the javascript environment which you are in, doesn't recognize the symbol, so I suggest you to try with the Unicode of that symbol. \u221A
var string = '√ foobar'
if (string.indexOf("\u221A") > -1) { alert(string); }