Meal maker: undefined


Hey guys so I have finally gotten through this project, the generateRandomMeal() function works as it should but when I console log the the function it return undefined with no error. Can someone show me where I went wrong ? Your replies are appreciated.

This is what is being logged to the console: ‘Your total is 16.75, potato wedges, oxtails, vanilla cake

Here’s a link to my code


Your setters do not look quite right. They are replacing the array with a value.


I figured everything out thanks for the reply but I gotta ask what is the purpose of the getter and setters if we are not using the setters explicitly to set anything ? like so menu.RandomSetter = 23;


With a plain object, the only way to modify a property is with a direct assignment, no logic or minimal logic involved. By giving properties their own getters and setters we expand their horizon to include functionality. A setter can introduce a range of criteria that any replacement value must adhere to, for instance. This would be one major reason for having a setter to oversee what values a property is replaced with, as opposed to permitting wholesale changes to a property.

const thermostat = {
  _roomTemp = 20,
  get roomTemp () {
    return this._roomTemp;
  set roomTemp (newTemp) {
    if (isNaN(newTemp) { return false; }
    if (18 <= newTemp && newTemp <= 22) {
      this._roomTemp = newTemp;


Ok I understand what your saying. What I was asking was what is the purpose of having the getters and setters within the meal maker project ?


Please post a link to this exercise so we can review the lesson text and look at our own code. Thanks.


Sure thing