Syntax error: unexpected identifier


#1

var slaying = true
var youHit = Math.floor(Math.random() * 2)
var damageThisRound = Math.floor(Math.random() * 5 + 1)
var totalDamage = 0

while(slaying) {

if (youHit === 1) {
    console.log("You hit the dragon!"); 
    totalDamage += damageThisRound;
   if(total damage >= 4) {
       console.log("You slew the Dragon!")
    slaying = false;
   }
   else {
   youHit = Math.floor(Math.random() * 2)
   }
}
else {
    console.log("The dragon defeated you...");
slaying = false
}

}

Where is my problem?


#2

   if(total damage >= 4) {
       console.log("You slew the Dragon!")
    slaying = false;
   }

It should be totalDamage, not total damage.