Meal Maker JS Project - help needed :)

Hey fellow coders!
I am having issues with the price property in the menu object. Here is my code:

const menu = {
  _meal: ' ',
  _price: 0,

  set meal(mealToCheck) {
    if(typeof mealToCheck === 'string') {
      return this._meal = mealToCheck;

  set price(priceToCheck) {
    if(typeof priceToCheck === 'number') {
      return this._price === priceToCheck;


menu.meal = 'Pasta';
menu.price = 7;


The issue I am encountering:
I tried to change the meal and price values with the setter method and then to log the menu object to the console. Since the value assigned to meal is a string and the value assigned to price is a number, the newely assigned values are supposed to be logged to the console.

However the value of the price property stays 0.

  _meal: 'Pasta',
  _price: 0,
  meal: [Setter],
  price: [Setter],

What could be the problem here?



Hi, in your set price method you are using a comparison operator === instead of an assignment operator =.

Instead of

return this._price === priceToCheck;

it should be

return this._price = priceToCheck;
1 Like