You call a timeout with parameter 1 , which means 1 millisecond for the timer event, but you treat this millisecond event as a full second in your redo() function.
redo () should be:
function redo() { s -= 0.001;
etc. However, given that running this code every milliseconds will lead to a rather large load on the browser and will not work accurate to the millisecond. When starting the countdown, you must track the TIME by recording the current system time using the Date () object, which has millisecond accuracy.
Call your repeat () at a longer interval than milliseconds (say, every 200 ms / 0.2 seconds), and then subtract the system time at that point from the start of the timer.
source share