JSFiddle - React, Tailwind, and code Playground
by qunzorez
JavaScript
function animateValue(id) {
var obj = document.getElementById(id);
var current = +localStorage.getItem('counter') || +obj.innerHTML;
obj.innerHTML = current;
function decrement(){
--current;
obj.innerHTML = current;
localStorage.setItem('counter', current);
if(current != 0){
setTimeout(decrement, (Math.floor(Math.random()*11) + 10) * 1000);
}
}
setTimeout(decrement, (Math.floor(Math.random()*11) + 10) * 2000);
}
animateValue('counter');