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

My solution for advance challenge given by Dave in loops,array and objects

var students = [
  {
    name : 'Ashish',
    track : 'Front-end web development',
    acheivments : 2,
    points : 1566
  },

  {
    name : 'Rohit',
    track : 'Python',
    acheivments : 1,
    points : 875
  },

  {
    name : 'Kapil',
    track : 'Php',
    acheivments : 1,
    points :975
  },

  {
   name : 'Ashish',
   track : 'Python',
   acheivments : 1,
   points : 255
  }
];

//print.js

var student;
var display;
var message ='';

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

 function find(){
      message += "<p> <b>Student : "+student.name + " </b></p>";
      message +="<p> Track : "+student.track + "</p>";
      message +="<p> Acheivments  : "+student.acheivments+"</p>";
      message +="<p> Points : "+student.points+"</p>";
     return message;
 }

while(true){
  var search = prompt("Type a name to search ---");
      if(search===null || search.toLowerCase==='quit'){
          break;       
      }
   for(var i=0;i<students.length;i+=1){

     student = students[i];
     if((search===student.name)){
        display = find();
        print(display);
     }
   }
  // here we're checking the condition for record which doesn't exist
  if(search!==student.name){
    alert("Not found");
  }
  //setting a message to empty string so the previous record display on a screen deleted
   message = '';
}