0
Variables are so baaaaaaad
I want to make a game that when you click on the play button you have some chances to have rewards(like a box openning like CSGO or etc...) and then you can see yours rewards at the left(for exemple if you get 3 money there will be show "đ° money" at the left) But my problem is when you got your reward and you want to replay, the variable "money" disappears and reset at 0 money. So if you get 2 money and after you get 3 money more you"ll don't have 5 money in the total but you"ll have 3 money in the total
5 Answers
+ 9
If you need help, post the code.
+ 7
coming from a c++ background, my mind tells me a static variable is the answer to your issue here. This may help in getting the results you require:
https://stackoverflow.com/questions/1535631/static-variables-in-javascript
+ 3
https://code.sololearn.com/W4VKE2d5Mhrs/?ref=app
+ 2
Because when you played for the second time the variable "money" was reset as if by magic at 0
0
I love programming