Hey guys, so I am going through the JS course at the moment and have a little question regarding loops.
When I run
var ten = 0;
while(ten <= 10) {
console.log(ten);
ten += 1;
}
I’ll get the console to print the numbers 1 to 11.
But when I run
var ten = 0;
while(ten <= 10) {
console.log(ten);
ten++;
}
I’ll get the console to print the numbers 1 to 10.
I thought
ten += 1;
should be the same as
ten = ten + 1;
am I doing / thinking something wrong here?