JSFiddle - React, Tailwind, and code Playground
by scriptstar
HTML
<!-- this is not good ->
/*
var jspy = {
count: 0,
incrementCount: function() {
this.count++;
},
decrementCount: function() {
this.count--;
},
getCount: function() {
return this.count;
}
};
*/
JavaScript
var jspy = (function() {
var _count = 0;
var incrementCount = function() {
_count++;
};
var resetCount = function() {
_count = 0;
};
var getCount = function() {
_count;
};
return {
add: incrementCount,
reset: resetCount,
count: getCount
}
})();
console.log(jspy.add(4));