How to make an animated number counter?

@midosaid88 this is the function you need. I hope you can understand, because it is a curried function.

const createTimer = (element, interval) => (startTime, endTime) => {
  let count = startTime
  const counter = setInterval(() => {
    element.text = count.toString()
    count++
    count === endTime && clearInterval(counter)
  }, interval)
  return counter
}

const timer1 = createTimer($w('#text1'), 1000) // element and interval
const timer2 = createTimer($w('#text2'), 500) // element and interval
timer1(1, 10) // startTime and endTime
timer2(1, 10) // startTime and endTime