Meal Maker : Property Access under method

For step 11, and on bullet point 3, why is price and name referred to immediately without any need to use the this keyword like below?

const totalPrice = appetizer.price + main.price + dessert.price;

return `Your meal is ${}, ${} and ${}

Isn’t price and name under the addDishToCourse method which would need the this keyword to refer to it?

addDishToCourse only adds the dishes to properties which you defined here:

const menu = {
  _courses: {
    appetizers: [],
    mains: [],
    desserts: [],

then getRandomDishFromCourse returns a random dish (which is an object with price and name property)

you can always use console.log() to log something if you are not sure of the value

1 Like