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!

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

Jesse Dispoto
.a{fill-rule:evenodd;}techdegree seal-36
Jesse Dispoto
Front End Web Development Techdegree Graduate 14,538 Points

Can someone critique my code, please?


First time doing this snapshot thing.... not sure if this is the correct way to do it?

Anyhow, could someone critique my code? Just want to get criticism on it. I did not open up Dave's solution yet, but my code does what the challenge required.

Somewhat unrelated... is there a way to directly post the snapshot on here instead of putting the link? I've seen others posts' that just directly show the code, and do not provide a link

Thank you!

The way to embed code in a Community post is to wrap it in triple-backticks, and specify the language after the first set of backticks. Like this:


// paste your javascript code here


Then it will look like this:

// paste your js code here

1 Answer

Hey Jesse,

I took a look at your code (and tried running), and I think you did a great job!

The array of objects (students) looks good. And your logic for using a for loop for both the number of students, and each item in the student object makes a lot of sense.

I was trying to think of some constructive things to help you, and could really only find two small things. Neither of which are huge, but rather suggestions.

1) The first thing I noticed is that there's a div in the HTML with the ID of "output." My assumption is that that's where Dave was looking for you to place the output of your code into the DOM. You could make a small change like this:

document.getElementById('output').innerHTML = html;

2) When reading over the second for loop: for (let student in students[I]), it was a bit confusing at first because of the variable name "student" that was used. When really you're looping over each key, or stat. Maybe renaming that variable something like "studentStat" or "studentInfo" would make it a bit easier for someone else to read:

for (let studentInfo in students[i])

Otherwise great work, for real!


No problem!