JSFiddle - React, Tailwind, and code Playground

by pollo

JavaScript

var counterf = function counterf(x) {
    return {
        inc: function () {
            return x += 1;
        },

        dec: function () {
            return x -= 1;
        }
    };
};

var counter = counterf(10);

alert(counter.inc());

alert(counter.dec());