JSFiddle - React, Tailwind, and code Playground

JavaScript

var Looper = (function (window, document, $) {
    
    this.i = 1;
    
    var Looper = function () {
        console.log('Created Looper Object...');
    }
    
    var getName = function () {
        return this.name;
    }
    
    var setName = function (newName) {
        this.name = newName;
    }

    var loop = function () {
        console.log(getName() + ' - ' + this.i);
        this.i = this.i + 1;
    }

    var startLoop = function () {
        window.setInterval(loop, 1000);
    }

    Looper.prototype = {
        getName: getName,
        setName: setName,
        start: startLoop
    }

    return Looper;
})(window, document, jQuery);

var one = new Looper();
one.setName('one');
console.log(one.getName());
one.start();

var two = new Looper();
two.setName('two');
console.log(two.getName());
two.start();