Not Printing As It Should - yet again

I thought that this code

var favRecipe = {
name:”Mole”,
serves:2,
ingredients:[“cinnamon”,”cumin”,”cocoa”]
};

for(var a=0 ; a < favRecipe.ingredients.length ; a++) {
textSize(20);
fill(190,180,170);
text(favRecipe.ingredients[a],0,25 + 25*a);
};

would print out

cinnamon
cumin
cocoa

but nothing happens - what am I missing ?

As long as you fix the quotes, it should work.

Ah those ■■■■ quotes again!! The worst part about it is that it isn’t anything that you can discern just by looking at the code you have typed. Smart quote - dumb quote - both look the same on the iMac. I have disabled the Smart Quote button on the iMac but as you have said, I guess that they can recur again in the Copy - Paste operation.

So when you say “fix the quotes” I find myself saying how? There are a lot of quotes in there and I haven’t a clue as to which ones have to be removed because they are smart quotes. So I thought that this is where Linter comes into play. Sure enough, Linter tells me that the problem is the quote preceding Mole in Line 2 (see above graphic).

So great - that seems to be the only fault in my code so what better place to correct it than in Linter? Actually, I thought that Linter would make the correction for me on its own, not just point out the fact that there’s an error. Since it didn’t make the correction, I placed a new double quote in front of Mole right in Linter. So then I get this

So I haven’t got a clue as to what this is. All I know is that I am stuck with a code that wont do what I want it to do. Yikes! This quote business is soooo discouraging!

The problem is the closing quote :wink: It needs to be replaced too.

Hopefully you’ve figured out your quote problem by now, but if you need help converting them, I made this little tool. Just paste your code in the white result area and it will automatically replace your quotes as soon as you do.

http://jsfiddle.net/6adzbL34/

So it’s this miserable semi colon that is at fault here? I would never have picked that up on my own so thanks for pointing that out to me. With respect to the tool that you have made - I presume that I just paste my block of code into the white space and presto the corrections are done - yes ? So what does Linter do then? Just point out the bad quotation marks without correcting them?

No, that shouldn’t cause any problems. Its not needed (semicolons aren’t used after if, while or for statements), but its also something that can be easily ignored by the compiler.

Yup. Its very simple. You can see the code in the jsfiddle. Its all right there. Its one line of html, one line of javascript, and some supporting css.

The linter points out errors and potentially problematic code or code that might follow poor coding practices. There’s a list of rules that is has that determine what it points out. You can see these by clicking on “Rules Configuration” on the website. Many of those rules listed can be configured more than the website offers, but the website gives you a pretty good idea of what it does already. It can also fix some of the problems it finds, but not all of them. The Fixed code tab on the website will show this. Given all that it does, though, I don’t think it focuses much on smart quotes. It will just see those as a syntax error since they break the code. I did a quick search, though, and it looks like there is a plugin for fixing smart quotes, so that’s what you would want :upside_down_face: .

Note that the website is just a demo. Normally you’d set this up on your computer and have your code editor drive the linting and show it in the code view much like the demo does with curly underlines (if you’re not using safari :stuck_out_tongue_winking_eye: ) and have the ability to fix those things it can automatically.

Whew !! I think I will just continue to plod along and make do with Linter as is. I am doing all this stuff through Khan Academy using Safari on the iMac and for the time being, I don’t want to give up the simplicity of this process.
—————————————————————————————

the code below doesn’t work

var favRecipe = {
name:”Mole”,
serves:2,
ingredients:[“cinnamon”,”cumin”,”cocoa”]
};

for(var a=0 ; a < favRecipe.ingredients.length ; a++) {
textSize(20);
fill(190,180,170);
text(favRecipe.ingredients[a],0,25 + 25*a);
};

same code put through the newly minted “senocular quote tool”

var favRecipe = {
name:“Mole”,
serves:2,
ingredients:[“cinnamon”,“cumin”,“cocoa”]
};

for(var a=0 ; a < favRecipe.ingredients.length ; a++) {
textSize(20);
fill(190,180,170);
text(favRecipe.ingredients[a],0,25 + 25*a);
};

and Presto !! Success !! I was worried that even though the “senocular quote tool” worked properly to get the right quotation marks into the code, that I may have lost that in the process of copying an pasting but no ! when stuck back into the code window it gave me the result I had been looking for -

so I am a very happy camper for the time being. Thanks for all your help. It is much appreciated.

Awesome! I noticed it didn’t work when you pasted the code back into the thread here - both of those code blocks are still using the smart quotes :laughing: