Practice makes perfect


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

is it R8?????


Hi the while statement has that structure

   #do something
   #stop the loop


var count = 0
var looop = function(){
while( count<3){ #As long as count is less than 3, the code will run
console.log (I'm looping!"); # prints "I'm looping!" as long as the while condition(count<3) is true.
count ++; #ups count by one for each time the while condition is true.


hey sayansayan,
first of all, you're missing a semicolon on the console.log.
And also, did you delete the last part where it calls the loop function?


also seliunm,
you for got a semicolon for var count = 0.
you also added an extra o in loop.
did you delete the part where it calls the function?
I think count ++ belongs in the parenthesis of the while loop


Hi everyone, can someone please explain how loop(); logs "I'm looping!” to the console ??

I made some notes below but I don't understand why this part is necessary..

var count = 0; //starts count at 0

var loop = function(){

		while(count < 3){ //will analyse values from 0 up to but not including 3

				console.log("I'm looping!");

				count++; //tells comp to add 1 each time function is called



loop(); //logs "I'm looping!” to the console



Found the answer here:


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