JSFiddle - React, Tailwind, and code Playground
JavaScript
function AnimateCount(CountTo, MSTime, FPS) {
var MSPerFrame = (1000 / FPS);
var step = (CountTo / (MSTime / MSPerFrame));
var Value = 0;
var Timer = setInterval(
function() {
Value += step;
if(Value >= CountTo)
{
clearInterval(Timer);
Value = CountTo;
}
document.body.innerHTML = Math.round(Value);
},
MSPerFrame
);
}
AnimateCount(100000, 2000, 60);