Hi all,
I’m having trouble getting my random quote machine to generate quotes. Could somebody help me please?
This is the link to my project:
Many thanks in advance.
Hi all,
I’m having trouble getting my random quote machine to generate quotes. Could somebody help me please?
This is the link to my project:
Many thanks in advance.
Take a look at the output in the JS console when you load the page. You’re going to see a syntax error in there that needs to be cleaned up first.
Yes, what bbsmooth said. I would also say that if you are going to use codepen, you should take your JavaScript code out of the script tags in your HTML and put them in the JS panel.
Ok, I’ve moved the JavaScript out of the script tags and in to the JS panel.
But still struggling to work out why there is an error with my generate quote function. It says in the console that “generateQuote is not defined”.
OK, I don’t get that error - perhaps you’ve changed something. I do see another problem. I don’t know why an error isn’t thrown for it, but in your definition of the quotes, you have something like this for each quote:
{
quote: "We learned more from a three minute record than we ever learned in school."
author: "Bruce Springsteen"
},
Notice that here the coloring is off. The same is true in codepen - “quote” is purple and “author” is yellow. In the codepen IDE, they should both be purple - object properties are purple. The problem is that you do not have a comma after the first key/value pair. It should be:
{
quote: "We learned more from a three minute record than we ever learned in school.",
author: "Bruce Springsteen"
},
OK, it still doesn’t show up “correctly” in the markdown here, but it does in codepen.
When I add a comma at the end of the first key/value pair in each of those objects, your program works for me.
It worked! Thank you so much for your help!
Congrats, now work on its styling.