JSFiddle - React, Tailwind, and code Playground

JavaScript

function dosomething(output) {
  alert("Did something! " + output);
}

var MyNewObject = function() {
  // Accessible to functions because the functions are closures.
  var a=0; 
  var c=0;

  this.new1 = function(){
    a=5;
  }

  this.new2 = function(){
    c=6;
  }

  this.new3 = function(output){
    if (a < c){
      dosomething(output);
    }
  }
}

var objThatDoesNews = new MyNewObject();
objThatDoesNews.new3("first"); // Didn't do anything
objThatDoesNews.new1(); // Set a to 5
objThatDoesNews.new2(); // Set c to 6
objThatDoesNews.new3("second"); // Did something!