Please help (while loops)


var count = 0;

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



Unclear what the problem is


i think you posted in the wrong place. this is for git lessons.


So, I'm guessing you're looking into this lesson:

Your loop does not work because the while condition is wrong. Remember that "as long as the condition evaluates to true, the loop will continue to run. As soon as it's false, it'll stop." In this case while(count) neither evaluates to true nor to false. (Technically, it evaluates to 0 === true which is false, and if I'm right, it would not loop at all)

Also remember what you learnt in for loops! :slight_smile:

for (var i = start; i < end; i++) {
  // do something

The while condition is not that different. After setting your count to 0, you need to provide a condition for it such that it evaluates to true/false, and then break out of the loop after three times.

Finally, loop(count) would mean loop(0), which does not provide any meaning for the computer. A function does not always need to have parameters! They only need parameters when they need to utilize the value to do something (for instance, value * 2, but in this case, simply calling loop is sufficient to activate the function.


thank you :heart_eyes:


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