Meal Maker - Unexpected token const

In the generateRandomMeal function, on the variable dessert I am receiving an error stating that SyntaxError: Unexpected token const. I believe that it has something to do with how I am initializing the getRandomDishFromCourse function. Please let me know if you have figured out the issue.

getRandomDishFromCourse: function(courseName) {
    
    const dishes = this._courses[courseName] 
    const randomDish = Math.floor(Math.random() * dishes.length)
    
    return dishes[randomDish]
   
}, 
  generateRandomMeal: function () {
    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}, ${dessert.name}, $${totalPrice}`
  }

The problem aside, we should examine the methods as you have them constructed. ES6 methods are written differently…

methodOne () {

},
methodTwo () {

}

Rewrite your methods and see if the problem persists.

1 Like