Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Why won't the citation change when the button is clicked

I am unable to change the citation when the button is clicked in the first project (Random Quote).

Steven Parker
Steven Parker
243,656 Points

To make it possible to help, please show your (formatted) code and provide a link the course page you are working on.

You can share the entire project at once if you make a snapshot of your workspace and post the link to it here.

Here is a snapshot: https://w.trhou.se/o8i3xogyd3. I don't understand what is wrong with code inside the styles.js file.

4 Answers

Steven Parker
Steven Parker
243,656 Points

Do you mean the "styles.css" file? Look at the line that loads it:

  <link rel="stylesheet" href="css/styles.css">

This code is attempting to load the file from a sub-folder named "css", but your snapshot shows that you have no such folder in your file organization. You can either create one and move the file into it, or you can change the code to load the file in from where it is now.

Note that you have a similar issue with the loading of the JavaScript file. And once you get it loaded, it has a syntax error on this line:

//Here we choose our random quote
var UsedQuote = (getRandomQuote,1)[0];

Did you mean: quotes[RandomNumber] instead?

No I wanted to stay script.js sorry.

Steven Parker
Steven Parker
243,656 Points

Both "styles.css" and "script.js" have the same issue with a missing sub-folder.

I think the folder didn't completely duplicate this workspace is better : https://w.trhou.se/xy6njx63rl . But unfortunately the quote still doesn't change.

Steven Parker
Steven Parker
243,656 Points

It will when you fix the syntax error I pointed out in my original answer. :wink:

I changed it but now it only works once. https://w.trhou.se/n8zmucb758

Steven Parker
Steven Parker
243,656 Points

Now you have "quotes[(RandomNumber,1)]", which will indeed only change it once.

What I suggested was "quotes[RandomNumber]", which would change it each time, though it might occasionally pick the same one being shown.

Thanks a lot!