This while loop is rather pointless as it just prints "You're Slaying" once.
The general idea of this "game" is pretty simple:
You have a dragon as opponent who has 4 HP.
And at the beginning of your game you first roll a 5 eyed dice to determine your damage (1-5 dmg) and flip a coin to determine whether you hit the dragon or miss.
And then the game starts:
Face the dragon:
Here you have 2 options: Hit or miss!
When the coin toss was not in your favor the dragon fries you: Game Over! Cruel but simple.
On the other hand when the coin toss was in your favor, you hit the dragon and reduce it's HP. Side note: Here you don't reduce HP but instead pile up damage until it reaches a threshold, which is a rather "interesting" design choice, but in the end the idea stays the same.
After the Hit:
Now you have again 2 options: "Slay or Wound"
If you were able to slay the dragon with this hit: Congratulations! You win! Game Over!
If you're not able to win with this hit, well try to set another hit:
- toss another coin to determine whether you hit or not
- Go back to "Face the dragon" and repeat the process
How to implement this?
So this last line of "repeat the process" is more or less the trigger word to use a loop, because loops are awesome when it comes to repetitive tasks. So basically everything after "And the game starts" is part of the while loop.
var slaying= true
Now you have 2 main options to deal with, as said, "Hit or Miss". Which could be done by an if/else statement. The else is fairly simply: negative Game Over message + ending the loop.
The if again splits into 2 options: "Slay or Wound". So again if/else statement this time nested in the if branch. Where the if branch of the nested one is again: positive Game Over message + ending the loop. And the else part is simply update the settings: toss the coin again.