Not sure I understand this error

hello, everyone here has been so helpful I hoped perhaps someone could shed some light on this issue.

I’m working on the menu generator module here: https://www.codecademy.com/courses/introduction-to-javascript/projects/meal-maker

So after reading this: InternalError: too much recursion - JavaScript | MDN
I am fairly sure the issue is my get and setter calls, however, I am at a loss as to how to fix it. If I’m trying to get a particular item (i.e, appetizers) what else can I call it but what it is?

I think I’m just missing some important concept?

=====================================
MY ERROR MESSAGE

Error: 
c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:9
		return {
		^

RangeError: Maximum call stack size exceeded
    at Object.get _courses [as _courses] (c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:9:3)
    at Object.get appetizers [as appetizers] (c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:16:15)
    at Object.get _courses [as _courses] (c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:10:21)
    at Object.get appetizers [as appetizers] (c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:16:15)
    at Object.get _courses [as _courses] (c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:10:21)
    at Object.get appetizers [as appetizers] (c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:16:15)
    at Object.get _courses [as _courses] (c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:10:21)
    at Object.get appetizers [as appetizers] (c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:16:15)
    at Object.get _courses [as _courses] (c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:10:21)
    at Object.get appetizers [as appetizers] (c:\users\roxan\OneDrive\Documents\codeacademy\codeacademy\node_6c00ea1596bbb.tmp:16:15)

Info: End process (10:38:07 AM)

=============================
MY CODE:

const menu = {
	_courses: {
		appetizers: [],
		mains: [],
		desserts: []
	},

	get _courses() {
		return {
			appetizers: this.appetizers,
			mains: this.mains,
			desserts: this.desserts,
		};
	},
	get appetizers() {
		return this._courses.appetizers;
	},

	set appetizers(appetizers) {
		return (this._courses.appetizers = appetizers);
	},

	get mains() {
		return this._courses.mains;
	},

	set mains(mains) {
		return (this._courses.mains = mains);
	},

	get desserts() {
		return this._courses.desserts;
	},

	set desserts(desserts) {
		return (this._courses.desserts = desserts);
	},

	addDishToCourse(courseName, dishName, dishPrice) {
		const dish = {
			name: dishName,
			price: dishPrice,
		};
		return this._courses[courseName].push(dish);
	}, // end add dishtocourses

	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}, ${dessert.name}. The price is ${totalPrice}.`;
	}, // end generateRandomMeal function
}; // end menu

menu.addDishToCourse('desserts', 'Red Apple Pie', 8.75);

Recursion occurs when you call a function/method within itself. If you don’t provide an exit, it will recurse forever, much like an infinite while-loop.

You might want to look at your setters and getters and how they are returning things. Also, should your setters return any value at all?

Yes, thank you! I was playing around with another exercise and realized that my get calls don’t have to be named the same thing as what I’m calling. So, I changed this:

get someCourses() {

        return {

            appetizers: this.appetizers,

            mains: this.mains,

            desserts: this.desserts,

        };

Now it works shrugs Since I never refer to this getter name ‘someCourses’ I am not sure how that fixed it, but I’ll keep thinking about it. Thank you!