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

My code isn't working. It's not printing anything to the web page.

var message = ''; var student;

function print(message) { var outputDiv = document.getElementById('output'); outputDiv.innerHTML = message; }

for (var i = 0; i < students.length; i += 1) { student = students[i]; message += '<h2>Student: ' + student.name + '</h2>';

} print(message);

(This is the other part of the challenge.)

var students = [ { name: 'Dave', track: 'Web Design', achievements: '35', points: '1700' }, { name: 'Susan', track: 'Web Design', achievements: '45', points: '1920' }, {
name: 'Mike', track: 'JavaScript Developer', achievements: '18', points: '110' }, { name: 'Jenny', track: 'Web Design', achievements: '25', points: '900' }, { name: 'Rick', track: 'Web Design', achievements: '35', points: '1700' }

];

1 Answer

Steven Parker
Steven Parker
231,269 Points

This code seems OK, but the HTML part isn't shown and it's not clear if that might be causing the problem.

A better way to share the entire project at once is to make a snapshot of your workspace and post the link to it here.