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 trialBrian York
6,213 PointsMy HTML is off
I got the right output for this challenge, but the spacing in the HTML is off. Can anyone explain to me why this happens? I'm using un-ordered lists because it looks even goofier when I use ordered lists.
Here is the code that grabs the data from the array of objects:
var message = '<ul>';
for (var i = 0; i < students.length; i += 1) {
for (var key in students[i]) {
message += '<li>' + key + ': ' + students[i][key] + '</li>';
}
message += '</ul>';
}
document.write(message);
Thanks for the help, Brian
1 Answer
KRIS NIKOLAISEN
54,971 PointsNot sure what you want your output to look like but I think you want the closing </ul> tag:
message += '</ul>';
outside of your loop. Or your opening <ul> tag inside your loop.
for (var i = 0; i < students.length; i += 1) {
message += '<ul>';
for (var key in students[i]) {
message += '<li>' + key + ': ' + students[i][key] + '</li>';
}
message += '</ul>';
}