S
S
st3pkass2021-07-07 12:23:02
JavaScript
st3pkass, 2021-07-07 12:23:02

Variable not changing?

I wrote the code, according to the code it was written that the variable "MONEY" should change as a result of the message "Click 0.01", as a result, nothing changes. What could be the problem? Doesn't throw any errors and runs smoothly.60e572200e9c3828431244.png60e572589354b054498627.png60e57263e1c15213321471.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2021-07-07
@Stalker_RED

Vovan.money = 10; // У Вовочки было 10 рублей.
let gift = 5; // Бабушка решила подарить ему еще пять
Vovan.money += gift; // Сколько теперь денег у Вовочки?

Right now, you have in your head the knowledge that Vovochka has 15 rubles.
You are just like a computer, you read the source code, you execute the program, and the result is stored in your memory .
But in the source code , as it was written Vovan.money = 10, it remains so. This is how it should be - all these variables exist in the computer's memory while the program is running.
If you want to save them somewhere, you can use writing to a file, to a database, print it on paper or send it somewhere over the network (in telegrams, for example).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question