I have an object as follows
var shop = {
costPrice: function() {
return 100;
},
sellingPrice: function() {
var calculateProfit = function() {
return this.costPrice() * 0.2;
}
return this.costPrice() + calculateProfit();
}
};
console.log(shop.sellingPrice());
But this gives me the following error
objects.html:16 Uncaught TypeError: this.costPrice is not a function
at calculateProfit (objects.html:16)
at Object.sellingPrice (objects.html:19)
at objects.html:22
Not sure what I am doing wrong as costPrice
is a function