Can anyone spot something wrong with this?


#1


var height = 0
var growing = true
var growthThisTurn = Math.floor(Math.random() * 5 + 1);
var youGrew = Math.floor(Math.random() * 2);

while(growing) {
    if(youGrew) {
        console.log("You're getting bigger! and grew " + growthThisRound + " yay!");
        height += growthThisTurn;
        
        if(height >= 6) {
            console.log("You did it! You reached max height!");
            growing false;
        } else {
            youGrew = Math.floor(Math.random() * 2);
        }
            
    } else { 
        console.log("oh no... you didn't grow...");
        growing false;
    }
}


#2

Is this your own personal code?


#3

it is yeah, I'm doing the 'for or while' lesson 3, The story so far, if else and loops.


#4

So what error are you getting?


#5

SyntaxError: Unexpected token false


#6

try putting an equal sign in between. growing and false


#7

Nailed it, thank you very much!


#8

Happy to help! :grin:


#9

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