The project of meal maker


#1

sorry, but i follow the step and it is not working, please help

let menu = {
  _course:{
    appetizers: ['hello'],
    mains: [],
    desserts: [],
    },
  getAppetizers: function(){
    
  },
  setAppetizers: function(appetizerIn){
    
  },
  getMains: function(){
    
  },
  setMains: function(mainIn){
    
  },
  getDesserts: function(){
    
  },
  setDesserts: function(dessertIn){
    
  },
  getCourses: function(){
    return {
      appetizers:
      this._course.appetizers,
    }
    return {
      mains:
      this._course.mains,
    }
    return {
      desserts:
      this._course.desserts,
    }
  },
  addDishToCourse: function(courseName, dishName, dishPrice){
    let dish = {
      name: dishName,
      price: dishPrice,
    }
    return this._course[courseName].push(dish);
  },
  getRandomDishFromCourse: function(courseName){
    let dishes = this._course[courseName];
    const randomIndex = Math.floor(Math.random()*dishes.length);
  },
  generateRandomMeal: function() {
  let appetizer = this.getRandomDishFromCourse('appetizers');
    let mains = this.getRandomDishFromCourse('mains');
    let desserts = this.getRandomDishFromCourse('desserts');
    let totalPrice = appetizer.price + mains.price + desserts.price;
    return `Your meal is ${appetizer.name},${main.name},${dessert.name}. The price is ${totalPrice}.`
}
};
menu.addDishToCourse('appetizers', 'Caesar Salad', 4.25);
menu.addDishToCourse('appetizers', 'Tomato Salad', 5);
menu.addDishToCourse('appetizers', 'Cheese and Bread', 3);
let meal = menu.generateRandomMeal();
console.log(meal)

https://gist.github.com/cf57152f6b9682b104fd046c9d6070a4


#2

You are not using getters and setters as intended.

  _courses: {
    _appetizers: [],

    },

  set appetizers: function () {

  },

  get appetizers: function () {

  }
};

Please remember to include a link to the exercise or project. We do not have them on speed-dial, and need to know the exact page you are on. Also, include any error messages. Thanks.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.