Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
216,810 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.