Hi All!
I’m trying to figure out the below challenge. I need to update the amount of all dairy purchases to 25. Imagine I can do this via looping to update the array - any thoughts, advice? I feel like the solution is likely so simple, but I’m just stuck. Maybe I need some sleep.
class Food {
constructor(type, name) {
this.type = type;
this.name = name;
}
get type() {
return this.type;
}
get name() {
return this.name;
}
}
class Purchase {
constructor(amount, food) {
this.product = product;
this.amount = amount;
}
get amount() {
return this.amount;
}
setAmount(amount) {
this.amount = amount;
}
get product() {
return this.product;
}
}
const creamFood = new Food("dairy", "Cream");
const baconFood = new Food("meat", "Bacon");
const yogurtFood = new Food("dairy", "Yogurt");
const milkFood = new Food("dairy", "Milk");
var purchase = [ new Purchase(2, cream_food), new Purchase(1, yogurt_food), new Purchase(12, bacon_food), new Purchase(15, cream_food) ];