Javascript Array Foreach Function Example Math Proof