Skip to content Skip to sidebar Skip to footer

Javascript, Increase Number Day By Day

I need to write a code with javascript which increase the given number and sum it with a random range numbers and finally displays it. This has to be saved, because the next day,

Solution 1:

If your aim is a client-side application and you don't have to support old browser I would suggest to use local-storage. With local-storage you can save your value. The next day you open the browser with the JavaScript-App and it will update your number. Instead starting the app manually you can use e.g. the timeout function.

Solution 2:

Also, you could use your own simple pseudo-random generator, which would calculate current day value depending on the initial numbers (maybe stored in cookies) and a current date. It could save space, because cookies are very strict in size.

Post a Comment for "Javascript, Increase Number Day By Day"