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

Function start

assets/js/animatedCounter.js:4–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2const speed = 1000
3
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})
28}

Callers

nothing calls this directly

Calls 1

updateCountFunction · 0.85

Tested by

no test coverage detected