'totalPrice' variable on line 77

Is not being used, it seems like it should be reachable:

// Created by Paul A. Gureghian in May 2020. //
// This JavaScript program creates a three-course meal //
// Based upon what is available on a menu. //

// Start of program. //

// Create an object named "menu". //
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, 
        };
    
        return 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 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 ${appetizer.name}, ${main.name}, and ${dessert.name}, and the total price is ${totalPrice}";
    }
};

// Add dishes to courses. //
menu.addDishToCourse('appetizers', 'salad', 4.00);
menu.addDishToCourse('appetizers', 'wings', 4.50);
menu.addDishToCourse('appetiizers', 'fries', 5.00);

menu.addDishToCourse('mains', 'steak', 10.25);
menu.addDishToCourse('mains', 'salmon', 7.75);
menu.addDishToCourse('mains', 'pasta', 11.20);

menu.addDishToCourse('desserts', 'ice cream', 3.00);
menu.addDishToCourse('desserts', 'cake', 4.50);
menu.addDishToCourse('desserts', 'pie', 3.50);

// Call 'menu' object method 'generateRandomMeal()'. //
const meal = menu.generateRandomMeal();

console.log(meal);

// End of program. //

Perhaps I misunderstand your question. the variable totalPrice is being used on line 79

As far as I can tell it is not reachable to anything outside of the function generateRandomMeal
as it is include in the local scope of that function.

its grayed out in my editor and eslint reports it as unused

What editor are you using?
You should be able to test if it is unused by commenting it out, if it is used an error should appear when you try to run the program.

It is unused. You typed the name on line 79, but what you typed is simply a string.

That’s how the instructor did it in the video.

Two things. First, when you add your third appetizer there is a typo in the course name, a double i

menu.addDishToCourse('appetiizers', 'fries', 5.00);

Second, like @midlindner said, you are returning a string with this:

return "Your meal is ${appetizer.name}, ${main.name}, and ${dessert.name}, and the total price is ${totalPrice}";

You want to use a template literal, which requires `

1 Like

Single quotes ? instead of double quotes ?

nope, it looks a simple quote but it’s skewed to the right

`this is a template ${literal} using the backtick(`) `
'this uses simple quotes'
1 Like

Thanks. all good now. I have been jumping back and forth between JS and Ruby.