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

Anthony Scott
PLUS
Anthony Scott
Courses Plus Student 9,001 Points

Here is what I did

It works but is very different from the teacher's solution. Thoughts?

var student = [
  { Name: "Anthony",
   Track: 'iOS',
   Achievements: 5,
   Points: 100
  },

    { Name: "Sophia",
   Track: 'JavaScript',
   Achievements: 23,
   Points: 200
  },

    { Name: "Debra",
   Track: 'Ruby',
   Achievements: 9,
   Points: 1000
  },

    { Name: "Tim",
   Track: 'Web Design',
   Achievements: 50,
   Points: 10003
  },

    { Name: "Jane",
   Track: 'Web Design',
   Achievements: 12,
   Points: 500
  },

];

function print(message){
    document.write(message);    
}

for (var i = 0; i < student.length; i += 1) {
    var message = "<p><h1>Student: " + student[i].Name + "</h1></p>";
    message += "<p>Track: " + student[i].Track + "</p>";
    message += "<p>Achievments: " + student[i].Achievements + "</p>";
    message += "<p>Points: " + student[i].Points + "</p>";
    print(message);   
}

1 Answer

Michael Davis
PLUS
Michael Davis
Courses Plus Student 12,508 Points

Not bad, would be perfect for an overview list :-)

The only critique I have is that this is more of a "static" list. In order to allow the user to search for a student, you would have to re-write the same code into a function to allow searching. Having said that, re-writing code and experimenting is the best way to learn :-D