8. When to 'while' and when to 'for' (while loop)


#1

I can't seem to figure out what i'm doing wrong on the while side. Here's my loop:

var whileLoop = function() {
    var myCondition = 1;
    while(myCondition <= 5) {
        console.log("Looped!");
        myCondition++;
    }
}

This seems to output nothing. What have i done wrong? Thanks in advance!


#2

You need to call the function whileLoop by whileLoop() the loop itself seems to be ok.


#3

Well whaddya know. Worked a charm. Not sure how i missed that. Thanks!