Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 === true)
- {
- console.log ("You hit the dragon");
- totalDamage += damageThisRound;
- if (totalDamage >= 4)
- {
- console.log ("You killed the dragon");
- slaying = false;
- }
- else
- {
- youHit = Math.floor(Math.random() * 2);
- }
- }
- else
- {
- console.log ("Sikee..Dragon owned youu");
- }
- slaying = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement