()
| 4 | function start(){ |
| 5 | counters.forEach(counter => { |
| 6 | const updateCount = () => { |
| 7 | |
| 8 | const target = +counter.getAttribute('data-target') |
| 9 | console.log("Targeting",target); |
| 10 | |
| 11 | const count = +counter.innerText |
| 12 | console.log(count); |
| 13 | |
| 14 | const inc = target / speed |
| 15 | console.log("Incrementing", inc); |
| 16 | |
| 17 | if(count < target) { |
| 18 | counter.innerText = count + inc |
| 19 | setTimeout(updateCount, 1) |
| 20 | } else { |
| 21 | counter.innerText = target |
| 22 | } |
| 23 | |
| 24 | } |
| 25 | |
| 26 | updateCount() |
| 27 | }) |