Having the following, local storage script, i'm looking for a way so that after 7 days, the balance will be reset, if balance is = 0. How should i do that?
var balance = localStorage.getItem('balance');
if (balance === null) {
// Not found, set value from database or wherever you get the value
balance = 50; // Or whatever value
} else {
// Convert the retrieved value to a number, since
// localStorage stores everything as string.
balance = +balance;
}
function updateBalance(newBalance) {
localStorage.setItem('balance', newBalance);
balance = newBalance;
}