JSFiddle - React, Tailwind, and code Playground

HTML

<div id="num">123</div>

JavaScript

function MyTest() {
  //constructor
  this.counter = document.getElementById('num');
};

MyTest.prototype.setCount = function(count) {
  return this.counter.innerHTML = count;
};
MyTest.prototype.currentCount = function() {
  return parseInt(this.counter.innerHTML);
};
MyTest.prototype.incrementCount = function() {
  return this.setCount(this.currentCount() + 1);
};
MyTest.prototype.decrementCount = function() {
  return this.setCount(this.currentCount() - 1);
};

const test = new MyTest();

test.setCount(5)
test.incrementCount()