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

Mohamed Hassanin
Mohamed Hassanin
6,517 Points

This is another solution, I did it

Another solution, I did it

var students = [
    {
        name: "Mohamed Ahmed Hassanin",
        track: "Front End Development",
        achievements: 17,
        points: 850,
    },
      {
        name: "Michel Jordon",
        track: "iOS Development",
        achievements: 12,
        points: 712
    },
      {
        name: "Jhon Stewart",
        track: "Android Development",
        achievements: 14,
        points: 650
    },
      {
        name: "Danial Noh",
        track: "PHP Development",
        achievements: 17,
        points: 800
    },
      {
        name: "Izak Benjammen",
        track: "Ruby Development",
        achievements: 7,
        points: 600
    },
      {
        name: "James Braker",
        track: "Design",
        achievements: 15,
        points: 812
    },
]



for (var i = 0 ; i < students.length ; i++){

        document.write('<h1>'+'Student: '+students[i].name+'</h1>');
        document.write('<p>'+'Track : '+students[i].track+'</p>');
        document.write('<p>'+'Achievements : '+students[i].achievements+'</p>');
        document.write('<p>'+'Points : '+students[i].points+'</p>');

}

1 Answer

Great solution. Very clean.

Also, this really won't affect much then having to write extra code but you could also combine the html tags with the section titles. View Below

  document.write('<h1>Student: '+students[i].name+'</h1>');
  document.write('<p>Track : '+students[i].track+'</p>');
  document.write('<p>Achievements : '+students[i].achievements+'</p>');
  document.write('<p>Points : '+students[i].points+'</p>');

The extra markup is redundant and unnecessary for this solution but great work nonetheless.