Get index of empty space returns wrong value
In JS I have a text line and I want to get the index of the first
occurrence of an empty space.
For example, this is my line:
gram somethin b
And this is my code:
index = line.indexOf(" ");
if (index == -1)
index = line.indexOf("\u00a0");
The problem here is that the result of the code is 13, but it should be 4.
Why doesnt it recognize the empty space after 'gram' as empty space? How
can I check?
No comments:
Post a Comment