Meal Maker please help

Hi I completed this meal maker several times now but getting same output as my random dishes object object, but when i am accessing array directly of the property it seems fine, so my guess is somthing worng with my randomizer of the dishes. Please kindly take a look thank you kindly.

const menu = {
    _courses : {
        appetizers: [],
        mains: [],
        desserts: [],
    },
    // all our getters
    get appetizers() { return this._courses.appetizers;},
    get mains() { return this._courses.mains},
    get desserts() {return this._courses.mains},
    // all our setters
    set appetizers(appetizers) { this._courses.appetizers = appetizers; },
    set mains(mains) { this._courses.mains = mains;},
    set desserts(desserts) {this._courses.desserts = desserts;},
    // returns a courses method for all menu
    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(courseName) {
        const dishes = this._courses[courseName];
        const randomIndex = Math.floor(Math.random() * dishes.length);
        return  dishes[randomIndex];
    },


    generateRandomMeal() {
        const appetizers = this.getRandomDishFromCourse('appetizers');
        const mains = this.getRandomDishFromCourse('mains');
        const desserts = this.getRandomDishFromCourse('desserts');
        const totalPrice = appetizers.price + mains.price + desserts.price;
        return( `Hope you enjoy your order appetizer: ${appetizers}, and for your main you choose: ${mains}, your pudding will be ${desserts}, total price to pay: ${totalPrice}`)
    }
}



menu.addDishToCourse('appetizers','Shoup of the day', 5.99);
menu.addDishToCourse('appetizers','Prawn coctail', 3.99);
menu.addDishToCourse('appetizers','Fresh baked chilli bread to share', 7.99);

menu.addDishToCourse('mains','10z sir lion steak', 17.99);
menu.addDishToCourse('mains','16z Ribeye steak', 20.99);
menu.addDishToCourse('mains','Vegan lion steak', 15.99);

menu.addDishToCourse('desserts','Chocolate ice cream', 7.99);
menu.addDishToCourse('desserts','Chocolate browny', 6.99);
menu.addDishToCourse('desserts','Cheese board to share', 15.99);


let meal = menu.generateRandomMeal();
console.log(meal);

You could print out what you’re doing

return( Hope you enjoy your order appetizer: ${appetizers}, and for your main you choose: ${mains}, your pudding will be ${desserts}, total price to pay: ${totalPrice})
}

you have to return ${appetizers.name} ... ${mains.name} ...

2 Likes