What is wrong?


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

while(slaying === true) {

if(youHit === true) {
    console.log("you hit");
else {
    console.log("you missed");



Why do you have the first line as var slaying = false;?
The instructions from the course instruct to have it read as true. Try that and see if it works?


when true it goes into an infinite loop and crashes,
I get this error when false -"Oops, try again. Make sure you log a message to the console to let the player knows if (s)he won or lost!"


The variable "slaying" should be initialized as true otherwise the while loop will never run.


Right. This is because you don't have the final variable change.

First thing first, change your variable back to true, as the instructions dictate.

Second, In section 3, it instructed you to change the slaying variable to false IN THE BODY OF THE LOOP.

So per the instructions on section 3, your code should look like this when you go into section 4:
var slaying=true;
var youHit=Math.floor(Math.random() * 2);
var damageThisRound= Math.floor(Math.random()*5 + 1);
var totalDamage=0;


Notice that within the while statement, it changes the slaying variable to false? This is so when you do add the if statement, it will prevent it from going into an endless loop.

At this point, you should be able to just follow the instructions in section 4 to add the if loops.