JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Build an Object Challenge, Part 2

Corey Draper
Corey Draper
3,452 Points

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);

Corey Draper
Corey Draper
3,452 Points

(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
195,547 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.