JavaScript, 81 77 74 7470 bytes
Saved 4 bytes thanks to Shaggy
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(_=>alert(a)alert,9,a)
Pretty lame JS solution. Consumes the values from the [3,1,1]
array from the right (pop()
). Registers a timeout to display the current value in the future. If a timeout was already registered, cancel it.
Relies on the dirty nature of var
, which hoists variable declarations.
Two times:
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(_=>alert(a)alert,9,a)
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(_=>alert(a)alert,9,a)
Three times:
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(_=>alert(a)alert,9,a)
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(_=>alert(a)alert,9,a)
var t,i=(i||[3,1,1]),a=i.pop()
clearTimeout(t)
t=setTimeout(_=>alert(a)alert,9,a)