Meal maker project: where does "get courses" get used?

I just completed the “meal maker” project and got it to work. But I’m still confused about a few aspects, most especially this:
What does the “get courses” part do?

From reading other questions, I see that some of the getter and setter methods aren’t necessary. But this one is: when I delete it the code no longer works.

More mystery: I added a console.log(‘test’) inside the getter method and the code worked but nothing got logged.

So: I know it’s necessary, but can’t figure out what it does.

Here’s my code:

let 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(appetizersIn) {
      this._courses.appetizers = appetizersIn
  set mains(mainsIn) {
      this._courses.mains = mainsIn
  set desserts(dessertsIn) {
      this._courses.desserts = dessertsIn
  get courses(){
    return {
      appetizers: this.appetizers,
      mains: this.mains,
      appetizers: this.appetizers

  addDishToCourse(courseName, dishName, dishPrice) {
    let dish = {
      name: dishName,
      price: dishPrice

  getRandomDishFromCourse(courseName) {
    let dishes = this._courses[courseName];
    let randomIndex = Math.floor(Math.random()*dishes.length);
    return dishes[randomIndex];

    let appetizer = this.getRandomDishFromCourse('appetizers');
    let main = this.getRandomDishFromCourse('mains');
    let dessert = this.getRandomDishFromCourse('desserts');
    let totalPrice = appetizer.price+main.price+dessert.price;
    return `Appetizer: ${}, Main: ${}, Dessert: ${}, Total Price: ${totalPrice}`;

menu.addDishToCourse('appetizers', 'hot pretzels with beer cheese', 5);
  menu.addDishToCourse('appetizers', 'maple and bacon brussels sprouts', 6);

  menu.addDishToCourse('appetizers', 'olive plate', 5);
  menu.addDishToCourse('mains', 'steak tips', 12);
  menu.addDishToCourse('mains', 'reuben', 10);
  menu.addDishToCourse('mains', 'piles of meat', 20);
 menu.addDishToCourse('desserts', 'donut waffles', 7);
  menu.addDishToCourse('desserts', 'piles of carbs', 20);
   menu.addDishToCourse('mains', 'berries n chocolate n maple n cream', 12);
let meal = menu.generateRandomMeal();

Thanks for any insights!

Hi bit7547509295,
I haven’t done the course you’re mentioning. But pasting your code and removing the “get courses()” part didn’t change the outcome.
As you are saying the code does never call that getter method. Could you please tell about the error you’re getting when removing the getter method?

Oh, my! You’re right. Now when I delete “get courses()” it’s fine. Not sure what was happening yesterday, but at least it’s doing what I expect now. Thanks for your help!