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 JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Build an Object Challenge, Part 2 Solution

My coding won't run for "Build and Object Challenge, Part II" In Javascripts Loops Objects and Arrays.

I spent four hours trying to debug my coding. I even wrote a version of this program that runs fine in my Chrome console but it still won't run in the Treehouse workspace for this instructional video. I strongly suspect it's the placement of the HTML page. In the video, it looks like it's between a closed CSS file and an open Javascript file, something that's impossible to replicate in the workplace. Has anybody else run into this problem? If so, how did you solve it?

Steven Parker
Steven Parker
231,268 Points

To facilitate analysis of your issue, make a snapshot of your workspace and post the link to it here.

6 Answers

Steven Parker
Steven Parker
231,268 Points

I'm not sure what you mean by "closed" and "open" files, but in the snapshot, the "index.html" file is inside the "js" folder, so it doesn't run automatically when you start the preview. And if you open it manually, it won't load the CSS or JS files because it's looking for them in folders that don't exist from that position.

If you move "index.js" from the "js" folder up to the main folder, it will start with the preview and also run your scripts.

Also, I noticed that in "students.js" a call to "print" is made at the end, but that function isn't defined until "student_report.js" is loaded. So you might want to change the loading order.

Update: I see you moved the file to the "css" folder but not to the main one. So try going to the "console" pane and entering this command (notice the period by itself at the end of the line):

mv -v css/index.html .

After that, select "refresh" in the left pane to display the new organization.

I don't see a refresh command anywhere in the console pane. I checked all the menu options. I'm using Chrome for a browser, by the way.

Steven Parker
Steven Parker
231,268 Points

The "refresh" is in the pop-up menu you should see when you right-click on the files pane (on the left). But as soon as you move the file, starting the preview should show your project correctly.

Here's the snapshot: https://w.trhou.se/b1uawdzll5

When I referred to opening and closing files I actually meant folders. Sorry for the confusion. I tried your solution but the website won't allow me to move the injex.js into the main folder. I've several times now. As for the print command, I've duplicated all the coding in the video exactly as it's presented. Do you have any other ideas?

Steven Parker
Steven Parker
231,268 Points

I was able to move the file just by holding the mouse down over the file name, then dragging down to the blank area beneath the file list and releasing the mouse.

If you're still unable to do that, you might create a new file of the same name ("index.html") at the top level, and then copying the contents from the other one into it.

And for the ordering issue, the organization in the video is a bit different. The video puts only data in "students.js" and keeps all the code together in "student_reports.js". But your files have the code divided between them.

Well, Steven, I'm not sure what to say here. I can't move ANY file into the main folder, even if I create new ones. I deleted a print function from one of the files otherwise my code is identical the code in the video.

Here's another snapshot: https://w.trhou.se/94bclima1p

Steven Parker
Steven Parker
231,268 Points

It looks like you managed to move it from the "js" folder into the "css" folder. I've updated my original answer with a new suggestion that may do the trick.

That seems to have done the trick but I'm curious to know why I couldn't move the index.html manually.

Steven Parker
Steven Parker
231,268 Points

It worked for me, but perhaps there's some issue with your platform or particular browser/version.

You might need to take that up with the Support folks.

Ok, thanks for your help.