JSFiddle - React, Tailwind, and code Playground

HTML

<head>
</head>
<body>
<div id="counter">0</div>
<a href="#">Click</a>
</body>

JavaScript

$(function() {
    var current = $('#counter').text();
    var endvalue = 50
    $('a').click(function() {
        var storedInterval = setInterval(function() {
            if (current === endvalue) {
                clearInterval(storedInterval);
            } else {
                current++;
                $('#counter').text(current)
            }
        }, 50)
    })
})