Hamburger is complemented by one or more stuffing
(not less than one).
However, when I use ...stuffing
result is undefined
.
Help me how to correct this task, so that it counts the cost of all the ingredients.
function Hamburger(size, ...stuffing) {
this.size = size;
this.stuffing = stuffing;
this.topping = [];
}
Hamburger.small = {
name: 'small',
price: 10,
kcal: 200
}
Hamburger.cheese = {
name: 'cheese',
price: 4,
kcal: 10
}
Hamburger.meet = {
name: 'meet',
price: 40,
kcal: 103
}
Hamburger.prototype.calculatePrice = () => {
let allCost = humb1.size.price + humb1.stuffing.price;
return `Total burger price: ${allCost}`
}
let humb1 = new Hamburger(Hamburger.small, Hamburger.cheese, Hamburger.meet);
console.log(humb1.calculatePrice());