JS Progress Bars | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

JS Progress Bars

So what im wondering is if you check the javascript for the heal function the only way i could find to not be able to use heal if health is at 100 is using the return. Is there any other way (particularly better/cleaner) to do this? https://code.sololearn.com/WNzAAOfYBsHl/?ref=app

1st May 2017, 8:43 PM
Dalton
Dalton - avatar
3 Answers
+ 27
function heal() { let health = document.getElementById("health") let mana = document.getElementById("mana") if (health.value < 100) { if (mana.value < 15) { health.value += 0; } if (mana.value > 15) { health.value += 10; mana.value -= 15; } } }
1st May 2017, 8:54 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
Thank you ValentinHacker!!! and i know Edward i just ran into this problem in the middle of creating it. Im going to make spells a dropdown list that includes heal
1st May 2017, 9:08 PM
Dalton
Dalton - avatar
0
you forgot function spells()
1st May 2017, 8:57 PM
Edward