Shouldn't this be `str.charCodeAt(i + 1)`? I don't see how this could work. Did you test it? Either way, you should add tests.