JSFiddle - React, Tailwind, and code Playground

by Jussia

JavaScript

var sushi = {
	getPrice: function() {
  	return 200
  },
 /*  addMasago: function() {
    return this.getPrice() + 100
  },
  addCaviar: function() {
    return this.getPrice() + 200
  } */
}
/* 
var decorator = {
   price: sushi,
  getPrice: function() {
    console.log('price', this.price)
      return this.price.getPrice()
    }
} */

var decorator = {
	getPrice: function() {
    console.log('price', this.price)
      return this.getPrice()
    },
	addMasago: function(val) {
  console.log('addMasago', val + 100)
  	//return val + 100
  },
  addCaviar: function(val) {
  console.log('addCaviar', val + 200)
  
  	//return this.getPrice() + 200
  }
}

var my = decorator.getPrice()
my = decorator.addMasago(my)
my = decorator.addCaviar(my)