Meal Maker project question


I have a question regarding Meal Make project. According to the exercise, I had to do the following:
Create an object menu
Create a private object _courses
under “_courses” I had to create three blank arrays “appetizers”, “mains” and “desserts” with no privacy settings and consequently I had to create get/set for each array.
under “menu” object I had to create a get call courses() that returns the values of the arrays in courses.

Now here is the problem:
After doing the whole instructions, the exercise threw a return errors on array references. I compared codes from an existing solution and I noticed that all items in _course object is private. So, the problems got fixed after I made them private too.

Exercise instructions:

_courses {
appetizers: [],
mains: [],

Throws return errors and calling the function addDishToCourse threw an error “addDishToCourse is not a function”

Solution found in various places

_courses {
_appetizers: [],
_mains: [],

Everything is fine

Can someone tell me why I had to make the items private while the instruction didn’t say so?

Thank you


In general, properties with getters and setters are private so that the variable is available for other use.

foobar = {
  _foo: [],
  _bar: [],
  get foo () {
    return this._foo;
  get bar () {
    return this._bar;
  set foo (newFoo) {
  set bar (newBar) {

console.log(,;    // [] [] = 'foo'; = 'bar';
console.log(,;    // ['foo'] ['bar']

Notice that all our calls use the public variable?