5. Practice Makes Perfect


#1


5.Practice Makes Perfect


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!");

`


#2

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


#3

Thank you so much! :smile:


#4

You're welcome. :grin:


#5

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


#6

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


#7

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:


#8

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


#9

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:


#10

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

What it is doing?


#11

I believe calling the loop() 3 times would result in "I'm loopin" being printed out 9 times?


#13

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


#14