Build a Recipe Tracker - Step 11

Tell us what’s happening:

I am confused as I am working, I get the error

Cannot read properties of null (reading 'length)

and many other errors, but what I don’t understand when the task asks for

For now, access the totalIngredients and difficultyLevel of recipe1 and set them to the appropriate results of function calls and arguments.

If I am right, the instruction is asking me to pass in the arguements in said functions, then what is wrong?

Your code so far

const recipes = [];

const recipe1 = {
  name: "Spaghetti Carbonara",
  ingredients: ["spaghetti", "Parmesan cheese", "pancetta", "black pepper"],
  cookingTime: 22,
  totalIngredients: null,
  difficultyLevel: ""
};

const recipe2 = {
  name: "Chicken Curry",
  ingredients: ["chicken breast", "coconut milk", "curry powder", "onion", "garlic"],
  cookingTime: 42,
  totalIngredients: null,
  difficultyLevel: ""
};

const recipe3 = {
  name: "Vegetable Stir Fry",
  ingredients: ["broccoli", "carrot", "bell pepper"],
  cookingTime: 15,
  totalIngredients: null,
  difficultyLevel: ""
};

recipes.push(recipe1, recipe2, recipe3);

function getTotalIngredients(ingredients) {
  return ingredients.length;
}

function getDifficultyLevel(cookingTime) {
  if (cookingTime <= 30) {
    return "easy";
  } else if (cookingTime <= 60) {
    return "medium";
  } else {
    return "hard";
  }
}

const recipe1TotalIngredients = getTotalIngredients(recipe1.ingredients);
console.log(recipe1TotalIngredients);

const recipe1DifficultyLevel = getDifficultyLevel(recipe1.cookingTime);
console.log(recipe1DifficultyLevel);

// User Editable Region
getTotalIngredients(recipe1.totalIngredients);
recipe1DifficultyLevel(recipe1.difficultyLevel);
// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36

Challenge Information:

Build a Recipe Tracker - Step 11

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-recipe-tracker/66fbcf750a62784cf11f5635.md at main · freeCodeCamp/freeCodeCamp · GitHub

For now, access the totalIngredients and difficultyLevel of recipe1 and set them to the appropriate results of function calls and arguments.

where are you setting the new value of the properties totalIngredients and difficultyLever for recipe1?

In the last line I am doing it so.

is that how you update the property of an object?

Thanks, I have to re-read it again and again, now finally got it.