Javascript Array Foreach Function Example Problems