use .charCodeAt() instead of looping.

the tests are passing.
also i converted tabs to spaces.