I don't understand this While loop condition


I do not understand this condition below, in particular, the number ==11 condition:

var number =0
var thisfunction = function(){
while (number, number ++, number <11){
console.log(" This number is smaller than 11")
number ==11


1) If I remove this line, then my browser crashes. I find this strange because in the While condition, the function is supposed to loop through from 0 to 10, so why can't it stop on its own there without the "number ==11" line?

2) Now if I replace that number 11 at the same "number ==11" line with 8, 12, or literally any other number, the program would run fine. Why? What does the computer understand this line as?


This is the setup of a for loop:

for (number; n < 11; n++) {


The ordering of the parameters is important...

(counter; conditional; step)

The correct usage of while is to include just a conditional expression that starts out evaluating to true.

while (number < 11) {


May be removed.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.