How do I stop from going into the negatives | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I stop from going into the negatives

If you click “Fight” then “Keep fighting” it will eventually go into the negatives can someone make it go to zero thanks (Feel free to add your name up top) https://code.sololearn.com/WcxHstyrj1Ux/?ref=app

20th Jan 2019, 9:38 AM
Trevor
Trevor - avatar
2 Answers
+ 1
https://code.sololearn.com/W7CYVP5jMe80/#js
20th Jan 2019, 10:48 AM
ODLNT
ODLNT - avatar
0
Can you use an if statement to avoid this? something like: if (x < ) { x = 0; } Your variable will never go below zero that way.
20th Jan 2019, 10:14 AM
marjel101
marjel101 - avatar