What did I do wrong? 11/11


#1

To finish up and prove your loop mastery, write three syntactically correct loops in the editor: one for, one while, and one do. Beware of infinite loops!

var Aisha = true;
while(Aisha) {
console.log("She is cool!");
Aisha = false;
}
for(var Aisha = true) {
console.log("Aisha");
Aisha = false
}
var Aisha = false;
do {
console.log(Aisha);
}
while(Aisha);

WHAT DID I MISS?


#2

The Instructions:
To finish up and prove your loop mastery,
write three syntactically correct loops in the editor:
one for,
one while, and one do. Beware of infinite loops!

the for-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for

the while-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while

the do-while-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while


#3

Can you just tell me specifically what I did wrong?


#4

Well that FOR-statement is NOT correct....
have a look at the syntax in
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for


#5

Breaking down your code,

var Aisha = true;

while (Aisha) {
    Aisha = false;
    console.log("She is cool!");
}

No problem that code written either way. The for statement, as @leonhard_wettengmx_n points out, is missing at least one parameter, the conditional expression. Consider,

for (Aisha = true; Aisha;) {
    Aisha = false;
    console.log("Aisha");
}
console.log("Bye");

The for statement initializes Aisha, then the conditional evaluates it. Once it is false it fails the condition. We should note that this is quite non-standard but I showed it so you could see the minimum requirement of a for statement. In fact, this would be legitimate:

Aisha = true;
for ( ; Aisha; ) {
    Aisha = false;
    console.log("Aisha");
}
console.log("Bye");

A more common form of a for statement will look similar to the following:

for (var i = 0; i < 3; i++) {
    console.log("Looping!");
}

Your final loop, the do-while statement is correct, in this instance. However, for safety, the assignment should be inside the code execution block:

 do {
    Aisha = false;
    console.log(Aisha);
} while (Aisha);

Hope this helps see things in the context of your code.