Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. var slaying = true;
  2. var youHit = Math.floor(Math.random() * 2);
  3. var damageThisRound = Math.floor(Math.random()*5 + 1);
  4. var totalDamage = 0;
  5.  
  6. while (slaying)
  7. {
  8. if (youHit === true)
  9. {
  10. console.log ("You hit the dragon");
  11. totalDamage += damageThisRound;
  12. if (totalDamage >= 4)
  13. {
  14. console.log ("You killed the dragon");
  15. slaying = false;
  16. }
  17. else
  18. {
  19. youHit = Math.floor(Math.random() * 2);
  20. }
  21. }
  22. else
  23. {
  24. console.log ("Sikee..Dragon owned youu");
  25. }
  26. slaying = false;
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement