title: JavaScript TypeError, Cannot read property of undefined, but the function is defined. What am I doing wrong?
body: <p>I keep getting the error:
  "TypeError: Cannot read property 'push' of undefined" </p>
  
  <p>The error is in this line: "this.courseName.push(dish);"</p>
  
  <p>Here is the code:</p>
  
  <pre><code>let menu = {
      _courses: {
        _appetizers:[] ,
        _mains:[],
        _desserts: []
      },
  
      addDishToCourse(courseName, dishName, dishPrice){
          const dish = { name: this.dishName, price: this.dishPrice };
  
          // ERROR HERE: **this._courses[courseName].push(dish);**
      },
  };
  </code></pre>
  
  <p>I have been stuck with this error for hours. Is there something I'm not seeing? </p>
  
  <p>Sorry if there is a simple solution to this. I'm relatively new to JavaScript.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I was indeed calling the key incorrectly. I am now calling the function as: </p>
  
  <pre><code>  menu.addDishToCourse("_appetizers", "random", 10);
    console.log(menu._courses._appetizers);
  </code></pre>
  
  <p>When I log this in compiler it returns:</p>
  
  <pre><code>    [ { name: undefined, price: undefined } ]
  </code></pre>
  
  <p>It seems like the function isn't getting called. Am I approaching this fundamentally incorrectly?</p>