The second if statement wont work because of syyntax error


#1

code:
var slaying=true

var youHit=Math.floor(Math.random()*2)

var damageThisRound=Math.floor(Math.floor()*5+1)

var totalDamage=0

while(slaying){

if(slaying===1){

    console.log("Good job! You hit the dragon!")

    totalDamage+=damageThisRound; 


    if(totalDamage>=4){
        console.log("You slew the dragon!")
        saying=false

        }

        else{

          youHit=Math.floor(Math.random()*2);
            }





else{

    console.log("Oh no!You suck and the dragon deafeted you!")}



slaying=false}

#2

after the Brackets u need a semi-colon
console.log("Oh no!You suck and the dragon deafeted you!");


#3

thx man let me see if it works


#4

actualy u need a semi colon in all statements


#5

oki so all of the statements?


#6

it dosent work:pensive:


#7

if(slaying===1){

console.log("Good job! You hit the dragon!");

totalDamage+=damageThisRound; 

if(totalDamage>=4){
    console.log("You slew the dragon!");
    saying=false
    } else if() {
      youHit=Math.floor(Math.random()*2);
        } else{
           console.log("Oh no!You suck and the dragon deafeted you!");
         }
    slaying=false

}

i think this should work


#8

it says unexpected token }


#9

provably there is a curly brace that shouldn't be there {}


#10

Yeah I got my mistake thx men


#11

no problem, have fun :wink: