Meal Maker project help

I’m doing the Meal Maker project here in the Javascript course and am trying to play around with the code as suggested in the deeper learning section at the end.
It suggested creating an array of meals and prices to randomly set the special, which I’ve done with no problem. But then I decided to try to link each randomly selected meal to a specific price, and I can’t figure out how to do it. Here is my code so far

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);
  get todaysSpecial() {
    if (this._meal && this._price) {
      return `Today's special is ${this._meal} for $${this._price}!`;
    } else {
      return "Meal or price was not set correctly!";
const mealOptions = ["curry", "pizza", "lasagna", "toastie"];
menu.meal = mealOptions[Math.floor(Math.random() * mealOptions.length)];

let mealPrice = () => {
  if (menu.meal === "pizza") {
    return (mealPrice = 3.5);
  } else {
    return (mealPrice = 2.5);
menu.price = mealPrice();

When I run the code it logs this to the console: “Today’s special is pizza for $2.5!” where the meal name changes but the price is always 2.5, in other words the if clause in the mealPrice function never evaluates to true. Why not?

You’d have to change the setter for .meal to accept arrays instead of strings (like using Array.isArray() ) so that ._meal can become an array.

Also, why do your setters have a return? Set methods don’t need a return - their purpose is to possibly change something in the object, not to return a value.

Thanks for your reply but that’s not the problem - the result of mealOptions[Math.floor(Math.random() * mealOptions.length)] is always a string so the randomly selected meal is working fine.
The issue is that the price never changes.

I have actually just realised the problem - I had menu.meal in the mealPrice function, and it should have been menu._meal. It is now all working perfectly.