Eishta Mittal
Oct 1, 2021

--

Why is the condition in sleep function

'Date.now() > startTime + delay' ?

This will be equal to false on the first run only and the loop breaks... the purpose of sleep is not fulfilled.

It should be Date.now() < startTime + delay

as we need to loop till the current time becomes greater than startTime + delay

--

--

Eishta Mittal
Eishta Mittal

Written by Eishta Mittal

Software Engineer passionate about Frontend Engineering

No responses yet