It's not a typo, in common programming language, esp. for
.substring(), 1st character is at position 0. 32nd character is at position 31 (starting from 0). Even though the doc is using psuedo-code, we are using JavaScript as the base.
lol. sorry.

I don't have much idea about javascript. But in Excel, entering =mid(31,40) gets me the substring from the 31st place.
Ooops. Oh well, Microsoft...