Fix a bug with variable scoping (len refers to the SAME VARIABLE in both loops)
let should really be implemented by browsers