Hello all,
How many times is it defined? Since the function declaration is in forEach(), i assume that it is declared three times. Is that true?
const followerNumbers = document.querySelectorAll(".follower-numbers");
followerNumbers.forEach((x) => {
x.innerText = "0";
const target = +x.getAttribute("data-target");
console.log(target);
const increment = target / 200;
const updateCounter = () => {
//console.log("updateCounter Tanımlandı");
const c = parseInt(x.innerText);
if (c < target) {
x.innerText = `${Math.ceil(c + increment)}`;
setTimeout(updateCounter, 1);
} else {
x.innerText = target;
}
};
console.log();
updateCounter();
});
//Are we defining updateCounter method for each of the elements?
You can find the whole project here.