Meal maker parameter issues

Hey there, down the on line 32 of the code when I type the parameters for addDishToCourse they do not get entered as parameters as the writing is still in red, code below

const menu = {

_courses:{

appetizers: [],

mains: [],

desserts:[]

},

get appetizers(){

return this._courses.appetizers;

},

get mains (){

return this._courses.mains;

},

get desserts(){

return this._courses.desserts;

},

set appetizers(appetizers) {

this._courses.appetizers = appetizers

},

set mains(mains){

this._courses.mains = mains

},

set desserts(desserts){

this._courses.desserts= desserts

},

get courses() {

return{

appetizers: this.appetizers,

mains: this.mains,

desserts: this.desserts,

};

},

addDishToCourse(courseName, dishName, dishPrice) /// why are the parameters not coming up as them

{const dish= {

name: dishName

price: dishPrice

}

this._courses[courseName].push(dish)

}

getRandomDishFromCourse(courseName) {

const dishs = this._courses[courses]{

const randomIndex= Math.floor(Math.random)()* dishes.length)

return dishs.length[randomIndex]

}

}

generateRandomMeal () {

 const appetizer= this.getRandomDishFromCourse('appetizers')

const mais= this.getRandomDishFromCourse(‘mains’)

const dessert= this.getRandomDishFromCourse(‘desserts’)

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

return Your mean is ${appetizer}, ${main}, and ${dessert} and the total is ${total.Price}

}

}

menu.addDishToCourse(‘appetizers’, ‘salad’, 4.00 )

menu.addDishToCourse(‘appetizers’, ‘Wings’,4.50 )

menu.addDishToCourse(‘appetizers’, ‘fries’,4.00 )

menu.addDishToCourse(‘mains’, ‘steak’, 10.25 )

menu.addDishToCourse(‘mains’, ‘salmon’,7.25 )

menu.addDishToCourse(‘mains’, ‘tofu’,11.20 )

menu.addDishToCourse(‘desserts’, ‘ice cream’, 3.00 )

menu.addDishToCourse(‘desserts’, ‘coffee’, 3.00 )

menu.addDishToCourse(‘desserts’,‘cake’,3.25 )

const menu = menu.generateRandomMeal()

console.log

  • You’re missing commas in dictionaries.
  • On line 1 you define meal as a const and then try to redefine it later at the end.
  • Math.floor(Math.random)() * dishes.length) to Math.floor(Math.random() * dishes.length)
  • In getRandomDishFromCourse(): courses doesn’t exist and you have a typo dishs. You’re also not returning a meal but trying to index the length of dishes.
  • In generateRandomMeal(): two typos, mais and total.Price. You’re printing a dictionary, you want appetizer.name etc. You’re not returning a string as well.
1 Like