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 Multiple Items with Arrays Build a Quiz Challenge, Part 2

Andrew Alvarez
Andrew Alvarez
7,286 Points

The new print function makes the website to show nothing.

Hey guys!, I coded the answer in a different way with relatively the same result but when I use the new print function my site won't display anything and will show no error in the console.

//var message = ''; //var student;

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

for (var i = 0; i < students.length; i++) { for (var keys in students[i]) { pagePrint(keys + ' : ' + students[i][keys] + '<br/>');

} pagePrint('<br/>'); // console.log(students[i]); }

Robert Maziar
Robert Maziar
557 Points

Hello,

was this the result you were looking for?

var message = 'This is your message'; var students = [];

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

for (var i = 0; i < students.length; i++) { for (var keys in students[i]) { pagePrint(keys + ' : ' + students[i][keys] + '<br/>'); }

}

pagePrint(message);

// console.log(students[i]);

Brendan Moran
Brendan Moran
14,052 Points

This course has been replaced with a new course, because browsers no longer allow manipulation of the DOM during a while loop. Check out the new course: https://teamtreehouse.com/library/javascript-and-the-dom-2