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 1

My solution to part 1

var students = [
  {name: 'Elena Torrey', track: 'Front End Web Development', achievments: 1005, points: 3456;},
  {name: 'Lionel Messi', track:'iOS', achievments: 507, points: 3872;},
  {name: 'Cristiano Ronaldo', track: 'Web Design', achievments: 297, points: 9084;},
  {name: 'David Beckham', track: 'Python', achievments: 803, points: 6209;},
  {name: 'Neymar', track: 'JavaScript', achievments: 452, points: 6197;}
];

5 Answers

Brian Mendez
Brian Mendez
7,734 Points
var students = [

  {
    name: "Brian",
    track: "Front-End Development",
    achievements: 8,
    points: 1036
  },
  {
    name: "Joe",
    track: "Ruby",
    achievements: 10,
    points: 1430
  },
  {
    name: "John",
    track: "UI/UX",
    achievements: 23,
    points: 3450
  },
  {
    name: "Bob",
    track: "Python",
    achievements: 3,
    points: 230
  },
  {
    name: "Chris",
    track: "iOS",
    achievements: 4,
    points: 800
  },
];
Charles Willden
Charles Willden
12,357 Points
var students = [
  {name: "Abel", track: "iOS", achievements: 20, points: 2400},
  {name: "Barbara", track: "Web Design", achievements: 15, points: 1360},
  {name: "Christine", track: "Front End", achievements: 29, points: 3560},
  {name: "Dave", track: "Ruby", achievements: 45, points: 4512},
  {name: "Ernie", track: "Python", achievements: 15, points: 1200}
];
var html = "";

function print(message){
  var divout = document.getElementById('output');
  divout.innerHTML = message;
}

for(var i=0; i < students.length; i++){ 
  for(var key in students[i]){
    if(key === "name"){
      html += "<h2>" + students[i][key] + "</h2><ul>"; 
    }else{
       html += "<li>" + key + ": " + students[i][key] + "</li>"
    }
    html += "</ul>"
  }
}

print(html);

Looks good!

Ozgur Parlakkilic
Ozgur Parlakkilic
8,399 Points

var students = [

{ name: "Dave", track:"Web-Design", achievements:20, points:4000, }, { name: "Josh", track:"Web-Developer", achievements:17, points:3780,}, { name: "Mary", track:"iOS", achievements:13, points:3254, }, { name: "Kate", track:"Javascript-Developer", achievements:40, points:10232,}, { name: "Brian", track:"Python-Developer", achievements:10, points:3254,}, ];

for(var prop in students){ console.log(students[prop]); }