Bug? Cannot "Save & Submit Code" for lesson 6


There's nothing left to do in lesson 6 (Javascript > Dragon Slayer > 6 Well Done), but when I click "Save & Submit Code" the cursor changes but nothing happens and page becomes unresponsive. Not a big deal since I can manually skip, but please check/fix. FYI I've reproduced on two different computers (was using chrome both times though; I'll try to vary that later).


Well Can you take a quick screen shot of that?


I just figured it out; the default code has an infinite loop when the dragon slays you (i.e. I had to add "slaying = false;" there, see third-last line below). It's just a bit misleading since the text suggests there's nothing you need to do. And I guess it might have been missed since it only happens sometimes depending on roll of the dice. Here's my final code (I only added the 3rd last line):

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) {
console.log("Good! You hit the dragon!!");
totalDamage += damageThisRound;
if (totalDamage >= 4) {
console.log("Wow!!! You slew the dragon!!");
slaying = false;
} else {
youHit = Math.floor(Math.random() * 2);
} else {
console.log("The dragon defeated you easily.");
slaying = false;

So I recommend changing the text, or else making the default code have this extra line. Thanks!