While loops #5


#1


Im not sure what Im doing wrong and the loop at the bottom (outside the local code) is really confusing me. please help


//Remember to set your condition outside the loop!
var count = 0;

var loop = function(displayMsg){
	while(count < 3){
	console.log("I'm looping!");
	count+++;
	}
};

loop();


#2

You defined an argument but didn't use it.

It is either ++count or count++.


#3


thanks a lot


Replace this line with your code.


#4

Any idea why this is making the page crash?

//Remember to make your condition true outside the loop!
var myCondition = true;

var soloLoop = function(soloLoop = true){
while (soloLoop= true) {
console.log("Looped once!");
myCondition = false;

}
};

soloLoop();


#5

Assignment in function and loop.

Condition not being used.


#6

I see what you mean with the double assignment, but how do I use the condition?


#7

You must put it in the while condition. :slight_smile:


#9

What variable should be put in function ?

var count===0;

var loop = function() {
while( count < 3) {
console.log("I'm looping!");
count++;
}
};

loop();


#10

You are comparing rather than assigning.


#11

thanks for your help ! never forget again :smiley:


#14

This topic was automatically closed after 12 hours. New replies are no longer allowed.