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

Hrithik Sharma
Hrithik Sharma
6,090 Points

My Solution To This Challenge

My solution is little bit simpler. It's Here what are your thought: This one Javascript File

var students = [
    {
        name: "Hrithik Sharma",
        track: "Front-end Web Developer",
        achievement: 40,
        points: 3418
    },
    {
        name: "Jack",
        track: "Front-end Web Developer",
        achievement: 42,
        points: 5000
    },
    {
        name: "Lucy",
        track: "Python Beginner",
        achievement: 35,
        points: 3000
    },
    {
        name: "Ron",
        track: "C# Beginner",
        achievement: 40,
        points: 7056
    },
    {
        name: "Jasmine",
        track: "Back-end Web Developer",
        achievement: 40,
        points: 4056
    }
]


for (i = 0; i < students.length; i++) {
    document.write("<h2> Student " + (i+1) + "</h2>");
    for (const prop in students[i]) {
        if (prop.toLowerCase() == "name") {
            document.write("<h3>"+ prop + ": " + students[i][prop] + "</h3>");
        } else {
            document.write("<p>"+ prop + ": " + students[i][prop] + "</p>");
        }    
    };
    document.write("<br>");
}

This one is CSS (just for little Styling)

body{
    width: 30%;
    margin: auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-transform: capitalize;
}