I'm trying to get the counter variable saved when the page refreshes. For example, if the counter is at 5,000 then after refresh the counter will start back up at 5,000 and keeps saving so it doesn't start at the default value.
var count = 309000000;
function tick(){
count += Math.round(Math.random()*3);
$('#test').text(count.toLocaleString());
count;
setTimeout(tick,Math.round(1000+Math.random()*3000));
}
tick();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<p id="test"></p>
This code I have sets the default variable to 309,000,000 but everytime I refresh the page the value doesn't save and go back to the default. Please assist on where to start with this. I've looked at local storage and cookies but don't quite understand it.