Sunday, February 17, 2013
How to kill a dragoon!
//Another fun Codecademy exercise to learn using variables and while loops and if/else statements.
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===1){
totalDamage+=damageThisRound;
if (totalDamage>=4){console.log("Congratulations! You are by far the best reptiles'slayer, you bring back home the dragoon's treasure.");}
else {youHit=Math.floor(Math.random()*2);
slaying=false;}
console.log("You spanked da dragoon very well with your spear!!!");}
else {console.log("Da dragoon just flayed you alive, your skin will be used for crafting its winter coat.");}
slaying=false;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Please, comment!