11. Infinity Loop


I'm sure I'm messing this somewhere in here, but I'm not sure where. This is crashing. Is the while/do loops messed up?

Thanks for looking!
var dragon = true;
var dragon = function (){
while (dragon)
for (var health = 100; health<1; health--)

while(dragon <1)
console.log("not sure");
} while (dragon);



First of all please use more variable then just dragon because your dragon = true; gets directly overwritten by the dragon function and a function as condition doesn't make much sense.


We cannot use the same variable name for both the control and the function.

var flag = true;
var dragon = function () {
    while (flag) {
        flag = false;

This should get you started toward a solution.


I either type too slow, or try to say too much. Keep getting my toes stepped on. Wish there was some way to check out a question so we're not trampling over each other.


:smile: yeah for the second time. Guess the problem is that we instant reply on a watched topic and the time distance was therefore to short to see the answer. But I'm off soon anyway. Good night!


Please don't take this as an objection, as much as an apology. Nobody wants you to go (unless you have a warm pillow awaiting).


No, everything cool, a warm pillow is awaiting me just checking the recent messages :smile:


Okay, cool. Have a good night!


I had my function as dragonFight. Why I changed it, no idea.


changed the function name and now it all works. Thanks guys!