Meal Maker // Console.log issue

Hi guys! I have a problem with unexpected console.log result. I would appreciate your kind help.

So, instead of:

Your meal is this meal and that meal.  

I get:

Your meal is appetizers mains desserts.

Here is my code:

const menu = {
  _courses: {
    	_appetizers: [],
      _mains: [],
      _desserts: [],
    get appetizers() {
        return this._appetizers;
    set appetizers(appetizersIn) {
    get mains() {
      return this._mains;
    set mains(mainsIn) {
    get desserts() {
      return this._desserts;
    set desserts(dessertsIn) {
  get courses() {
    return { 
      appetizer: this._appetizers, 
      main: this._mains,
      dessert: this._desserts
  addDishToCourse(courseName, dishName, dishPrice) 	 {
    	let dish = {
			name: courseName,
  		price: dishPrice
  getRandomDishFromCourse(courseName) {
    const dishes = 
    const randomIndex =  
 Math.floor(Math.random() * dishes.length);
  return dishes[randomIndex];
  generateRandomMeal() {
    const appetizer = this.getRandomDishFromCourse('appetizers');
    const main = this.getRandomDishFromCourse('mains');
    const dessert = this.getRandomDishFromCourse('desserts');
    const totalPrice = appetizer.price + main.price + dessert.price;
    return `Your meal is ${} ${} ${}. The price is: ${totalPrice}.`;

menu.addDishToCourse('appetizers', 'Chips & Salsa', 4.25);
menu.addDishToCourse('appetizers', 'Onio soup', 3.55);
menu.addDishToCourse('appetizers', 'Spinach & Artichoke Dip', 4.75);
menu.addDishToCourse('appetizers', 'Mozzarella Sticks', 3,45); 
menu.addDishToCourse('mains', 'Shrimp', 7.25);
menu.addDishToCourse('mains', 'Smoked Turkey Leg', 8.65);
menu.addDishToCourse('mains', 'Ceasar Salad', 3.35);
menu.addDishToCourse('mains', 'Southern Fried Chicken Salad', 4.80);
menu.addDishToCourse('desserts', 'Brownie Bite', 3.50);
menu.addDishToCourse('desserts', 'Carrot Cake', 4.00);
menu.addDishToCourse('desserts', 'Triple Chocolate Meltdown', 4.25);
menu.addDishToCourse('desserts', 'All-American Apple Pie', 5.15);

let result = menu.generateRandomMeal();

Either you’re looking in the wrong place or the right place has the wrong information. You should know what information you mean should exist there, so you should immediately be able to say which is the case, and then you can either look in the right place instead, or you can fix the code that is responsible for putting the wrong information there.

Hmmm. :thinking: I followed exact steps from the video provided and the problem still persists; I’m getting the same result. It’s so frustrating. :confused:

p.s. Thanks for your reply.

Be careful with the word exact, it means something.
Since the nature of the bug says a lot about where the problem is, you could compare those part closer.
I’d also suggest focusing on what is supposed to happen when the code runs rather than what text is supposed to be copied.
In any case, I don’t think that project is particularly meaningful, I guess it tries to teach getters and setters but it doesn’t use them to any advantage so it’s entirely contrived and difficult to understand what’s being done. So, you know, you might not want to bother finishing it. But then again, fixing your bug on the other hand is something worth investigating because that’s an important skill to have.

1 Like

Hi I know its a bit late, but you have a mistake in your addDishToCourse method. You have set name to courseName but it should be dishName. So you are actually naming all your courses either ‘appetizers’, ‘mains’ and ‘desserts’. Your dishNames are never being used.

hope that helps.

You are absolutely right! I made the change and now everything is as it should be. Thanks for your reply.