Meal maker error: maximum call stack size exceeded

i am stuck on this issue for a while now and need help i’m hoping its just something i missed because i cant see whats creating this maximum call error. if someone has fixed this before it would be great to see and learn from that thanks

here is my code

const menu = {
_courses : {
appetizers: ,
mains: ,
desserts: ,

get appetizers() {
return this.appetizers;
set appetizers(appetizerIn){
this.appetizers = appetizerIn;

get mains() {
return this.mains;
set mains(mainsIn) {
this.mains = mainsIn;

get desserts() {
return this.desserts;
set desserts(dessertIn) {
this.desserts = dessertIn;

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

const dish = {
name: dishName,
price: dishPrice,

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 total = appetizers.price + mains.price + desserts.price;
return Your meal is ${}, ${}, ${}. The price is $${total};


menu.addDishToCourse(‘appetizers’, ‘salad’, 7);
menu.addDishToCourse(‘appetizers’,‘nuggets’, 6);
menu.addDishToCourse(‘appetizers’, ‘pizza’, 7);
menu.addDishToCourse(‘mains’,‘steak’, 20);
menu.addDishToCourse(‘mains’, ‘fish’, 18);
menu.addDishToCourse(‘mains’, ‘pasta’, 15);
menu.addDishToCourse(‘desserts’, ‘pudding’, 7);
menu.addDishToCourse(‘desserts’, ‘cake’, 7);
menu.addDishToCourse(‘desserts’, ‘slice’, 6);

let meal = menu.generateRandomMeal();

1 Like

Your title says it all. You’ve got a function calling itself so many times thaht javascript refuses to keep track of any more calls (needs to remember where to return to, and current variables there)


yes i understand that my current code is creating an infinite loop that is maxing out the calls, i suppose what i’m meaning is that i am not understanding completely why the error is pointing at the get _courses return line, when im creating dishes not trying to get then at that point

1 Like

all good i realised where i had gone wrong the end bracket after i created my app, main and desserts arrys was suppose to be at the end of all the getter and setters not before them , i knew i missed a character somewhere finally found it. =)

1 Like

This is an issue that Occurs in a lot of languages in different ways. We were Taught how to fix problems like this @ Harvard, but still takes me a while to figure it out cause I’m a nube when it comes to syntax.

1 Like

I don’t see how a misplaced bracket would cause this. Your getter references itself, moving brackets around or re-ordering definitions doesn’t change that.
All there should be to solving that problem should be reading the error message, noting where the call is made, and edit it to use whatever it was supposed to use instead (no guessing or looking for single characters that might be off should be needed)


moving the bracket didn’t solve my problem completely, by doing so the error changed and i was then able to see and fix my getter methods, it would have been easier to post my code and say how i fixed it but i know that is not what mods want to see happening on here, why the little detail in how i fixed it. sometimes you just need a different error to get your brain thinking another way haha