JSFiddle - React, Tailwind, and code Playground

by Matthew Day

JavaScript

var add = (function () {
    var counter = 0;
    return function () {counter += 1; console.log(counter); return counter}
})();

add();
add();
add();

// the counter is now 3