Unit 4 Section 11 Review: Writing for, while, do loops


#1

Can someone please tell me what is wrong with my code?

for (var i=0; i<10; i++){
console.log (i);
}

var count=true;
while(count === true){
console.log("I am correct");
count = false;
}

var purple = false;
do {
console.log("I am right");
}
while (purple);
};


#2

Remove the curly bracket and semicolon in your last line of code. Then, add some code that causes the do while loop to end. Otherwise, it will never stop running.


#3

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