What i have to do i realy lost in while


#1

count = 0

var loop = function(number){
while(var count=0;count<3;count++ )
{console.log("I'm looping!");
//Your code goes here!
}
};


#2

please give a link to the exercise you're on :slight_smile:


#3

This would for a for loop but I believe you're working on while loops.


#4

The way you could complete this while loop is by giving it a condition inside of parenthesis. You would only have to write while(count) and then you would open your curly braces and print I'm looping, (you did it correctly), but right after that on the next line, write count = 1 (or anything else). The point of assigning it a new value is so that your loop stops looping because it will create an infinite loop which is what you DON'T want.
Tell me if this helps!


#5

that the best what i can do and he give me 1 i "am looping" and i need 3
var count=true;

var loop = function(count){
while(count){
console.log("I'm looping!");
var count=false;

}

};

loop(1);


#6

Practice makes perfect on while cours


#7

you could loop 3 times with a while loop:

var loop = function(count){
	while(count is less then 3){
	    console.log("I'm looping!");
	    // increase count by one
      }
};
loop(1);

i wrote the solution in pseudo code, you will need to convert it to usable code. You could simply check if count is less then 3, then inside the loop, increase the counter by one.

It is different syntax then the for loop, but it can be done.


#8

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