JSFiddle - React, Tailwind, and code Playground

HTML

<button id="button" type="button">Upgrade 1</button>

JavaScript

function Upgrade () {
    this.price = 0;
}

Upgrade.prototype.buy = function() {
    this.price = 40;
}

var upg = new Upgrade(),
    button = document.getElementById("button");

button.onclick = function() {
    upg.buy();
    alert(upg.price);
};