5. Practice Makes Perfect

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
5.Practice Makes Perfect

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
I don’t understand why I get “Oops, try again. Hey now–only one console.log() call!”

... var count=0 var loop = function(){ while(count<3) { console.log("I'm looping!"); count++; } }; loop(); console.log("I'm looping!");
<do not remove the three backticks above>
1 Like

Remove the console.log that comes after you call your function,:slight_smile:

Thank you so much! :smile:

2 Likes

You’re welcome. :grin:

2 Likes

Can anyone explain why count++; comes after console.log and not after while, like in for loops usually?

Can anyone explain - Why are the parenthesis that come after function empty? Same with the parenthesis after loop?
Thanks

Is an increment of the loop.

It all depends on how you want the loop to function. Incrementing it before the console.log would result in an error or infinite loop. :slight_smile:

This is the function call when a function has no parameters the function call will have nothing in the parentheses. :grin:

remove the:

console.log(“I’m looping!”);

at the very bottom line then call the function 3 times that means you should add 2 more loop();

eg…

loop();
loop();
loop();

works for me :slight_smile:

Can anyone explain to me why
var loop = function() is in there.

What it is doing?

I believe calling the loop() 3 times would result in “I’m loopin” being printed out 9 times?

1 Like

If you need help create a +New Topic
With your code, error and lesson URL

1 Like