You are trying to perform the calculation from left to right, but it should be right to left, in other words, start at the end of the string.
Quote:
Code:
if (binary.charAt(i) === 1)
|
=== is the wrong operator because you are comparing an integerr to a character.
Try again.