When to "while" and when to "for".It says I need a bracket when it might not be needed


#1

Here is the code I'm using

var count = true
var i = 0
for (var i = 1; i < 11; i++) {
// Print the numbers 1 - 10
console.log(i);
}
while(count = true) {
console.log("Try again"!)

count = false;

};

SyntaxError: missing ) after argument list


#2

console.log("Try again"!)

! is an operator if it is not part of the string. Also this is not a good condition:

while(count = true) {

because = is an assignment operator so this count = true has a value of true (always) -> infinite loop.


#3

Right,thank you for help.