Dinamic text (shown progressive)

Is there any function, code or plug to be able to insert dynamic text on my page? I need to insert a number that is progressive (shown from 1 to 20) for the years of the company’s age.

Hi, MERCADOSCOPIO_LEARNI !!

Are you trying to achieve something like this? :thinking: By inputting the company’s founding year, I have made it so that the current age of the company is automatically calculated and displayed in the text. :wink:

$w.onReady(function () {

 displayCompanyAge(2004, "#companyAgeText");

});

function displayCompanyAge(startYear, elementId) {

    const currentYear = new Date().getFullYear();
    const companyAge = currentYear - startYear;
    $w(elementId).text = companyAge.toString();

}

Or perhaps you want to achieve something like a text animation where the numbers change from 1 to 20? :thinking:

$w.onReady(function () {

    startCounter(20);

});

function startCounter(maxCount) {

    let count = 1;
    let intervalTime = 1000;

    function updateCounter() {
        if (count < maxCount) {
            count++;
            $w("#counterText").text = count.toString();
			intervalTime *= 0.8; // count speed up !!
            setTimeout(updateCounter, intervalTime);
        }
    }

    updateCounter();

}