ok, i'm trying to make a simple text based game, but i keep getting an error when I try to call a function. Here's my code..
My guess is that i messed up trying to subtract. I don't recall seeing that in a book or on a website.
alert("You attack the monster for " + strength - m1defence + "damage.");
is that the part that is wrong?
Code:
<script> var health=15; var strength=30; var defence=10; var m1health=16; var m1strength=30; var m1defence=4; funtion attack() { if health > 0 { alert("You attack the monster for " + strength - m1defence + "damage."); alert("You have " + health + "health left."); alert("Your opponent has " + m1health + "left."); } else { alert("You are dead. You may not attack."); } </script>
alert("You attack the monster for " + strength - m1defence + "damage.");
is that the part that is wrong?
Comment