Random quote machine rogue semicolon

Random quote machine rogue semicolon
0

#1

I copied and pasted the “Change Text with Click Events” code into Codepen as a starting point on this challenge. However, I’m getting an error message regarding a semicolon in the script, and the button isn’t working. Any thoughts?

https://codepen.io/pyritohedron/pen/wPZjOJ .


#2

There shouldn’t be a semicolon at line 7.

The <script> tags in the JS editor will also cause errors, so remove them.

EDIT. The <script> tags are messing with the parsing of the code. There should be a semicolon at line 7.


#3

Agreeing with Kev and elaborating, you are misusing Codepen. For example, in the HTML, the only stuff in that HTML pane should be the stuff inside the body tags (without the body tags). Everything else is handled by codepen or you can add in the settings. This is different than how you do an HTML file when building locally or deploying, but this is the codepen sandbox. But that’s not what’s killing your code - if you leave this, it will still work.

Similarly (and as Kev pointed out) your main problem is those script tags in your JavaScript. You only use those when inserting JavaScript in an HTML file. You would never put them in a JS file or here, in the codepen JS pane. If you remove those script tags from your JS (lines 1 and 9), that will take care of that.

You will also need to load jQuery. In the “real” world you’d do that with a script tag in your HTML, but this is codepen you you do it with settings/javascript/quick-add.

When I do all that, your code works for me.


#4

Thanks guys, it’s working for me now.