JavaScript, Variable not Defined error


#1

Hi,

I am having an issue with my code, it says that ‘appetizers is not defined’ and i just can’t see the problem in my code. Mybe i am to close to it. Could you guys take a look at the code and maybe not immediately tell me the answer but give me some kind of hint…Thank you.

const menu = {
_courses: {
appetizers: ,
get appetizers() {

},
set appetizers(appetizersIn) {

}, 
mains: [],
get mains() {

	},
set mains(mainsIn) {
    
},
desserts: [],
get dessets() {

},
set desserts(dessertsIn) {

}

},
get courses() {
return {
appetizers: this._courses.appetizers,
mains: this._courses.mains,
desserts: this._courses.desserts
}
},
addDishToCourse(courseName, dishName, dishPrice) {
const dish = {
name: dishName,
price: dishPrice
}
this._courses[appetizers].push(dish);
this._courses[mains].push(dish);
this._courses[desserts].push(dish);
},
getRandomDishFromCourse(courseName) {
let dishes = this._courses[courseName];
let mathRandom = Math.floor(Math.random()* dishes.length);
return mathRandom;
},
generateRandomMeal() {
const appetizers = this.getRandomDishFromCourse(‘appetizers’);
const mains = this.getRandomDishFromCourse(‘mains’);
const desserts = this.getRandomDishFromCourse(‘desserts’);
const totalPrice = appetizer.price + mains.price + desserts.price;
return Your meal is ${appetizer.name}, ${main.name}, ... The price is $${totalPrice}.;
}
}
menu.addDishToCourse(‘appetizers’, ‘snacks’, ‘257 dollars’);
let meal = menu.generateRandomMeal();
console.log(meal);


#2

If you have

a = 3
b = []

and you want the 3, is it at b[0] ? No, that’s undefined. Where was 3 supposed to be? Maybe it should be moved, or maybe it is where it’s supposed to be but you looked somewhere else.

And if you don’t know the answers to those questions then you probably didn’t read the specification (instructions) well enough, so do that.