What is wrong with my syntax? Dragon Slayer exercise 1/6


#1



https://www.codecademy.com/courses/javascript-beginner-en-mrTNH-6VIZ9/0/2?curriculum_id=506324b3a7dffd00020bf661#


Every time I save and submit my code, the console replies with: "SyntaxError: Unexpected token".


Here is my code:

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

Please tell me what's my syntaxError. I REALLY need help guys.


#2

Unbalanced parenthesis.

More unbalanced parenthesis. :slight_smile:


#3

Try using our code
var slaying = true;
// A bit of new math magic to calculate the odds
// of hitting the dragon. We'll cover this soon!
var youHit = Math.floor(Math.random() * 2);
var damageThisRound = Math.floor(Math.random() * 5 + 1);
var totalDamage = 0;

while (slaying) {
if (youHit) {
console.log("You hit the dragon and did " + damageThisRound + " damage!");
totalDamage += damageThisRound;

if (totalDamage >= 4) {
  console.log("You did it! You slew the dragon!");
  slaying = false;
} else {
  youHit = Math.floor(Math.random() * 2);
}

} else {
console.log("The dragon burninates you! You're toast.");
slaying = false;
}
}