8. Syntax error expected ")"


#1

var i = 1
while(i = 1; i < 101; 1--) {
console.log(i)    
    var i = i - 1
};
// SyntaxError: Unexpected token ';'. Expected ')' to end a while loop condition.

#2

what is this? i need help!


#3

This is incorrect syntax for while() and looks more like for() syntax.

 1--

will always be 0. In a for loop we would write, i-- or i++ so the value of the variable is decremented or incremented, as applies. But this is moot since we are working on while()

We need a conditional expression that yields a boolean...

i = 0;
while ( i < 100) {
    console.log(++i);
}

This will output a list of numbers from 1 to 100 inclusive.


#4

thanks
'
'
'

'
'
'
'
'
'