Apologies if the title is confusing, allow me to clarify
Imagine I have a 2d array representing different flavors of ice cream and milkshakes
menu = [ ['vanilla', 'chocolate', 'almond'],
['vanilla', 'pineapple', 'strawberry'] ]
Now, I am creating a class that takes this array as an input
class cafe{
constructor(menu){
this.iceCreams = menu[0]
this.milkshakes = menu[1]
}
}
I want to set a 'price' property for each flavor of milkshake.
this.milkshakes[n].price = < a function that calculates price based on n >
This way, I can access them like so :
cafe.milkshakes[0].price
How can I include the index 'n' of the array when defining the property?
I haven't attempted anything yet as I'm unsure how to proceed ☹️