JSFiddle - React, Tailwind, and code Playground
HTML
<p>Counting with a local variable.</p>
<button type="button" onclick="myFunction()">Count!</button>
<p id="demo"></p>
JavaScript
function Add(x) {
this.counter = x;
return (function () {
return this.counter += 1;}).bind(this);
};
var add = new Add(0);
myFunction=function(){
document.getElementById("demo").innerHTML = add();
}