Property Access mistake?


So on Property Access it is explained that you can access each individual character in a string the same way you access things in an array.

And it gives the following example:

var hello = ‘Hello World’;
// Output: W

‘W’ will be the output since it’s the character in the 6th position. This works because JavaScript internally stores strings in a similar way that it stores arrays.

Correct me if I’m wrong, but if you start counting from 0 then wouldn’t the character in the 6th position be ‘O’ not ‘W’?

Thank you for your time.


I think you missed the space to count


Space is treated as a character in JavaScript. So “W” is in the 6th position.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.