Hi what's wrong in my code ? thanks!


#1

var count=0;

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

loop();


#2

What specific lesson, you need to provide the specific lesson and error you got for us to help you better.


#3

...in JS 5- "Practices makes perfect" in "Introduction to 'While' Loops in JS"

lesson


#4

Maybe have a look at this:


for examples on how a while loop works because atm your condition is rather out of place.


#5

First, declare your variable count equal to 0 and set up function name loop.

var count = 0;

var loop = function(){
};

Second, after setting up your function loop, create your while loop inside your function :

var count = 0;

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

The condition is less that 3 because the program asked to logs "I'm looping!" to the console three times thats why we declared the count = 0, so number that less that to 3 are 0,1,2. meaning our condition will print I'm looping 3 times

Lastly, call your function.

var count = 0;

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

loop();

Hope this helps


#6

Thanks very much ! It works ! I didn't thought you have to put "count++" after the first braces { . I thought we have to put it in function 's parenthèses () .

Thanks a lot Gracie017 !