Fix leading zeros being dropped in JavaScript