damageThisRound should change each round


The sample codes make damageThisRound a set value, which means you always deal the same damage to the dragon.

In my opinion, we should declare the damageThisRound variable within the while loop, so the value resets each round.

Below are my codes:

var slaying = true;
var totalDamage = 0;

while (slaying) {
    var youHit = Math.floor(Math.random() * 2);
    if (youHit) {
        var damageThisRound = Math.floor(Math.random() * 5 + 1);
        console.log("Yeah, you did " + damageThisRound + " to the dragon!");
        totalDamage += damageThisRound;
        if (totalDamage >= 4) {
            console.log("Congrats! You killed the dragon!");
            slaying = false;
    } else {
        console.log("Your hit missed and you are dead...");
        slaying = false;


That's silly. Of course it should be set every round :o

But then again, if learners see this flaw and correct it, that's good too
at the expense of their confidence in the exercises :p