MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / updateCount

Function updateCount

assets/js/animatedCounter.js:6–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4function start(){
5counters.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})

Callers 1

startFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected