JSFiddle - React, Tailwind, and code Playground

HTML

<button id="doit" value="doit"> SCOOP THE CREAM
</button>

JavaScript

var IceCream = function(flavor) {
  this.tub = 100;
  this.flavor = flavor;
};

IceCream.prototype = {
  scoop: function() {
    this.updateInventory();
    alert("scooping");
  },
  updateInventory: function() {
    this.tub--;
    alert(this.tub);
  }
};

var vanilla = new IceCream("vanilla");
vanilla.scoop();

$('button').click(vanilla.scoop);