I Thought I Had It Solved

this code should result in the following printout

Mmm … Mole!

Serves: 2

Ingredients:

cinnamon

cumin

cocoa

but I am not getting a printout - any idea why? - the code has been run through the Senocular quote tool so I don’t think it’s a quote issue unless the Copy - Paste operation has brought back the quote gremlins

var bestDessert = {

title:“Mmm … Mole!”,

servings:2,

ingredients:[“cinnamon”,“cumin”,“cocoa”]

};

textSize(30);

fill(100,90,200);

text(bestDessert.title,0,30);

text("Serves: + bestDessert.servings,0,60);

text(“Ingredients:”,0,90);

for(var i = 0,i < ingredients.length, i++) {

textSize(30);

fill(100,90,200);

text( bestDessert.ingredients[i],0,120 + 30*i );

}

You have some syntax and reference errors.

  1. "Serves: + is missing the closing quote before the +. It should be "Serves: " +

  2. The different parts of your for loop should be separated by semicolons (;) not commas (,)

  3. ingredients in your for loop should be bestDessert.ingredients

     for(var i = 0; i < bestDessert.ingredients.length; i++) {

Easy when you know what you are doing! That worked - slowly but surely I am beginning to get a feel for what this coding is all about - mainly - a lot more attention is needed when writing it - thanks !

It takes a while to get used to all the syntax and rules. Eventually it becomes easier. Until then you need to rely on linting and runtime error messages to help you figure out what’s wrong. They’re not always clear, and can require some additional investigation, but they should help point you in the general direction. You can also look at references like MDN to check on syntax for things like for loops assuming that could be at fault (which it was this time).