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 Student Record Search Challenge Solution

Mohamed Ahmed
Mohamed Ahmed
7,449 Points

That's my solution for the last challenge , I did it

That's my solution for the last challenge , I did it

var student;
var search;

var students = [
    {
        name: "Mohamed",
        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: "Mohamed",
        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
    },
]



while (true) {

    search = prompt('Type a Student Name or "quit" to Exit');

    if (search === null || search.toLowerCase() === 'quit'){

        break
    }

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

    var student = students[i]

    if (student.name.toLowerCase() === search.toLowerCase()) {

        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

Grace Kelly
Grace Kelly
33,990 Points

nice one, i love how neat your code is!! :)