JSFiddle - React, Tailwind, and code Playground

by Stepan Suvorov

JavaScript

var myShop = {
    proceedToCheckout: function (basket){
        //code to proceed to checkout here
    }
}

var Basket = function (id){
    this.id = id;
    this.items = [];
}

Basket.prototype = {
    removeItem: function (item){
        this.items.splice(this.items.indexOf(item), 1);
    },
    addItem: function (item){
        this.items.push(item)
    }

};

var basket = new Basket(1000);
basket.addItem({id: "pony", quantity});
myShop.checout(basket);