I am stuck on the end of ‘meal maker’ project in ‘objects’ part. The program says that it is not able to read ‘length’ property of ‘dishes’ in ‘getRandomDishFromCourse’. The part of the code, where error is shown, is given below.
const randomIndex = Math.floor(Math.random() * dishes.length);
The link you posted is to the specific exercise. If any of us follow it, we see our own code from the exercise not yours. You need to copy your code, and paste it in a post. Click on the </> icon first, and paste your code in the space indicated. Thanks!
we can see that calling getRandomDishFromCourse with argument value dessert gives undefined, looking at the properties of courses object we can see that the property is named desserts. Which explains the error
Is this how to share my code? Toward end of Meal Maker, i have to create dish object inside menu object. My word dish is blue but in the hint it’s red. Anyway, I can’t understand the hint or what I’m doing with this step. i watched the video a couple of times. Would anyone like to point me in the right direction/ Thank you!!
I guess I’m really not clear yet. the very first lesson told us to get in the habit of ending things with a semi colon.
then I learned that methods within objects should be separated by commas.
Maybe i need to google when to use each; thank you for directing me to the issue!!!
In the HINT, the color of the code for addDishToCourse is red,
but in my code, it’s light blue AND i get no error message AND it matches the color on the video help.
It might help me learn this if anyone could explain why both colors would work?
It’s not the colors, but the code that works. Syntax highlighting can vary from one environment to another. Work in a black on white setting for awhile and it will remove all the color from your mind and let you focus on the code.
Regardless the environment you work in after that the color will give off signals our brain can pick up on.