Help wanted! JS Meal Maker project

Learn JavaScript | Codecademy

Hello, friends! I am a little stuck here at step 10, need three more steps to finish but I also would like to receive comments about my code so far. What has to change and what to keep.

Thank you for your time.

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) {
    const dish = {
      name: dishName,
      price: dishPrice,
   };

   this._courses[courseName].push(dish);
  },

  getRandomDishFromCourse: function (courseName) {
    const dishes = this._courses[courseName];
    const randomIndex =Math.floor(Math.random() * dishes.length);
  }
  
};
  

You can remove the function keyword here which will increase the readability of your code. For example:

generateRandomMeal() {
   // Your code goes here 
}

And also leave a space after the equal keyword too.

1 Like

Ok, let me understand a little. The highlighted getRandomDishFromCourse is obstructing my code readability and so I have to switch it for generateRandomMeal?

If not, let me know your idea as instructions, like “step one: do this, step two, remove this”

because I am really dumb sometimes :sweat_smile: :joy:

Thank you friend for your prompt response to my issue.

I have already said it is an example here.

Ok, all my code in one function,

but then how to make it work correctly?

Take a look at the cheatsheet examples.

https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-objects/cheatsheet

1 Like

Step 10, point 4, instructs “Return the dish located at that index in dishes .”

Your getRandomDishFromCourse() doesn’t currently return anything. You have done the other bits, but not the point 4.

1 Like

Thank you so much for the help! I’ll fix this point right away!