While loop with strange result


#1

var i = 1;
while (i < 11) {
console.log(i * i);
i += 1;
};

This code gives me the following result:

1
4
9
16
25
36
49
64
81
100
11

why does it put an '11' at the end?


#2

i think it is codecademy runnning a test or something, if you would replace this line:

console.log(i * i);

by:

console.log(i * i + " is multiply of: " + i);

you will see that 11 stays 11, and not becomes 11 is multiply of ? (i put a question mark there, because i have no idea what it is), i think it is safe to ignore, if you run this outside of codecademy it should be good


#3

No its a feature of the console which echoes the last value unless it is undefined so what you see is the value of this statement:

i += 1;

Nothing to worry about here.