Practice Makes Perfect 5/11


#1

Write a while loop that logs "I'm looping!" to the console three times. You can do this however you like, but NOT with three console.log calls. Check the Hint if you need help!

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

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

loop();

WHAT DID I DO WRONG?


#2
they ask

"I'm looping!"

you use

"I'm looping"


#3

Hello,

I'm having the same kind of problem, even with the exclamation mark right where they want it to be. When I type the code beneath I get "Oops, try again. Hey now--only one console.log() call!" But why? I can't figure it out. Any hint would be appreciated. Thank you!

var i = 1;

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

loop();

#4

replace the "i" with "count" because that's what they want you to use also its suppose to equal 0 also they want you to use "3" not "4" this is my code....

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

loop();

#5

You get that Oops ... message from the course-checker.
The course-checker checks on th whole of the code-page
and if it finds more than 1 console.log on the code page
it will display... Hey now--only one console.log() call!

As i tested your code using a windows 8.1 IE11 environment,
i had to remove my code... as the more then 1 console.log condition occurred.
After removing my =code= I got a pass using your code...


#6

Also she 's missing the () around the console.log argument.


#7

The instructions imply that you're free to choose the way and the name of the variables. So although count is a common choice it's not mandatory. The only requirement is as @leon has mentioned that you use console.log only once. I tested your code ekrul and I can pass using this so maybe just refresh your page and try again.


#8

That's it! I had some more code on my page and even though it was commented out it must have caused the error message!

Thank you for your help! :smile:

ekrul


#9

Same issue/same fix. IMHO I would consider this a bug, if its commented out it shouldnt be evaluated.