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 Data Using Objects The Build an Object Challenge, Part 2 Solution

Anderson Martinez
Anderson Martinez
7,988 Points

my code wont show up. I am not sure what is wrong

here is my code. I am not sure what I am doing wrong

var students [
{name: "Sasha", track: "IOS", achieve:"50", points:"2300"},
{name: "Devora", track: "CSS3", achieve:"32", points:"1200"},
{name: "Morris", track: "C++", achieve:"78", points:"4000"},
{name: "David", track: "JavaScript", achieve:"64", points:"3400"},
{name: "Thanos", track: "Ruby", achieve: "99", points: "9999"}
];



var message = " ";
var student;



function print(message) {
    var outputDiv = document.getElementById("output");
    outputDiv.innerHTML = message;
}

for (var x = 0; x < students.length; x += 1){
    student = students[x];
    message += "<h2>Student: " + student.name + "</h2>";
    message += "<p> Track: " + student.track + "</p>";
    message += "<p> Achievement: " + student.achieve + "</p>";
    message += "<p> Points: " + student.points + "</p>";
}

print(message);
Austin Whipple
Austin Whipple
29,725 Points

I've edited your question to format your code block. As Steven mentioned in their answer, be sure to check out the Markdown Cheatsheet below the text editor for more information.

1 Answer

Steven Parker
Steven Parker
231,248 Points

It looks like you're missing the assignment operator ("=") on the top line where you initialize the "students" array.

When posting code in future, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.