Shouldn't damageThisRound reset on each youHit


#1

In the What you are building, damageThisRound will always be the same upon each hit. Instead, shouldn't it reset.

Something like this:

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("hit: damage " + damageThisRound);
totalDamage += damageThisRound;
if (totalDamage > 4) {
console.log("you win");
slaying = false;
}
youHit = Math.floor(Math.random() * 2);
damageThisRound = Math.floor(Math.random()*5 + 1);
} else {
console.log("miss. burned. gg");
slaying = false;
}
};


#2

@jonescr3 Yes it should. Maybe you can change your code to a suggestion Codecademy to fix instead of bieng an actual problem you cant identify. Thanks!