Thursday 15 September 2011

html - How do I get a variables value to be constantly decreased when operated on (+/- the requested change) (in javascript:alert boxes)) -



html - How do I get a variables value to be constantly decreased when operated on (+/- the requested change) (in javascript:alert boxes)) -

<script> var x = 40 function ale() { = document.getelementbyid("find").value if (a == 'spark' || == 'fire') { var monster = x var harm = math.floor(math.random() * 10) alert('enemy has ' + (monster - damage) + ' health!'); } else if (a == 'water' || == 'bubble') { var monster = x var damagew = 10 alert('enemy has ' + (monster - damagew) + ' health!') }

hi happens whenever type illustration water health of x 40 30 click 1 time again , tells me same thing 30 when want 20 , if type fire give me 20 - math.floor(math.random()*10) give 17 pretty much how text based game works. keeps giving me 30 everytime write water. possible x value working can edited maintain value after been edited illustration subtraction?

you have decrease x 10 if want 20 next time on click.x=x-damagew after alert.

javascript html variables alert

No comments:

Post a Comment