4. the first 'if' statement


#1

Im not sure what I did wrong here
is it a syntax error
Help me out!

var slaying = true;
var youHit = Math.floor(Math.random() * 2);
var damageThisRound = Math.floor(Math.random()*5 + 1);
var totalDamage = 0;
while(slaying === true){
   if (youHit === 1) {
       console.log ("You hit the dragon!");}
    else {
    console.log("You missed the dragon!");
    }
    slaying = false;
}

#2

Hi @axle_kim,

Could you please add what error you are encountering with this code? Just as a friendly reminder adding as much information on your question really helps everyone out :slight_smile:

I ran your code as is through Unit 4, Dragon Slayer Lesson 4 and it passed with no problems :slight_smile: Which is great ideally, but if you are encountering issues could you please let us know what issue and then someone will try to help as soon as they can.


#3


#4

Hi @bitace35576,

From your screenshot, we can see that your very first console.log() has an equals sign "=" after it and before the opening paren.

console.log= ("Slaying e falso");  //remove the = symbol

PS: In the most friendliest way possible :slight_smile: It's always better to start your own thread rather than hijack an existing one :wink:


#5

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