Can i get a correct codes for the Dragon Slayer?


#1

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;
}
}

Always "Oops, try again. It looks like you didn't set slaying to true." appear when i click the Save & Submit Code. I need some correct codes.


#2

Did you try

++++ reset of session *****************
As you are manipulating with objects
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

Addendum
General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom


#3

same the display error "Oops, try again. It looks like you didn't set slaying to true." appear when i click the Save & Submit Code. I need some correct codes.


#4

okay i got it......................................