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 trialAndrew Alvarez
7,286 PointsThe 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]); }
Brendan Moran
14,052 PointsThis 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
Robert Maziar
557 PointsRobert Maziar
557 PointsHello,
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]);