JSFiddle - React, Tailwind, and code Playground

JavaScript

item = function (parameters) {

    this.size = parameters.size || 5;
    this.color = parameters.color || 'red';
    this.price = parameters.price || 99.99;
    this.quantity = parameters.quantity || 1 ;
    
    
    this.get_total = function(){
        return this.price * this.quantity;
    }
   

}


var pants = new item({price:25.25,quantity:4});
var shirt = new item({price:33.33,quantity:6});


alert('pants before:'+pants.get_total())
alert('shirt before:'+shirt.get_total())

//lets add a function that adds tax... (to the ITEM prototype)

item.prototype.get_total_with_tax = function(){
    return this.price*this.quantity + (this.price*this.quantity)*.25
}

alert('new pants with new prototype tax:'+pants.get_total_with_tax())

var shoes = new item({price:10,quantity:10})
//now shoes have that...
alert('shoes with tax:'+shoes.get_total_with_tax())