Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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