2👍
✅
The issue you’re facing is related to the scoping of the timer
variable inside the leftBlinkTimer
function. The timer
variable is declared inside the function’s scope, so when you call clearInterval(timer)
, it won’t refer to the same timer
that was created in the previous call to leftBlinkTimer
.
declaring it outside would help
Source:stackexchange.com