JSFiddle - React, Tailwind, and code Playground

by Stepan Suvorov

JavaScript

var myShop = {

    baskets: [],
    
    getBasket: function(id){
        return this.baskets[id] || {item:[]};
    },
    removeFromBasket: function (id, item){
        var item = this.getBsket(id).items;
        items.splice(items.indexOf(item), 1);
    },
    addToBasket: function(id, item){
        this.getBasket(id).items.push(item);
    },
    proceedToCheckout: function(id){
        // code to proceed to cbheckout here
    }
}