JSFiddle - React, Tailwind, and code Playground
JavaScript
var universe;
$(function() {
universe = new Universe();
universe.timeStart();
});
function Universe() {
this.timer = 0;
this.tick = 0;
this.timeStart = function(){
this.timer = setInterval(this.timeForward, 500);
};
this.timeStop = function() {
clearInterval(this.timer);
};
this.timeForward = function(){
this.tick++;
console.log(this.tick);
};
}