I am executing the following seemingly straightforward code
var number = 0;
while (number <= 12) {
console.log(number);
number = number + 2;
}
If you slightly change your code:
CHROME
var number = 0;
while (number <= 12) {
console.log("z" + number);
number = number + 2;
}
z0
z2
z4
z6
z8
z10
z12
14
You'll see that the 14
is not being printed by the loop. Rather, that is the end value of the expression when the loop finishes running and is printed by the console itself.
FIREFOX
while (number <= 12) {
console.log("z" + number);
number = number + 2;
}
14
"z0"
"z2"
"z4"
"z6"
"z8"
"z10"
"z12"
In Firefox, it runs the entire loop, prints the result and then catches up with the console.