JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Student Record Search Challenge Solution

Cristian Corrales
Cristian Corrales
Front End Web Development Techdegree Student 7,638 Points

My Extra Credit Solution

var reply;
var counter = 0;
var obj;
function print(message) {
  var outputDiv = document.getElementById('output');
  outputDiv.innerHTML = message;
}


do{
  reply = prompt("Please enter a name");
  if(reply === null || reply === ''){
  break;
  }
  for(var i = 0; i < students.length; i++){
    if(students[i].name === reply){
      counter+= 1;
      if(counter === 2){
        message += "<br><h3>Name: " + students[i].name + "</h3>";
      }
      else {
      message = "<h3>Name: " + students[i].name + "</h3>";
      }
      message += "<h3>Track: " + students[i].track + "</h3>";
      message += "<h3>Achievements: " + students[i].achievements + "</h3>";
      message += "<h3>Points: " + students[i].points + "</h3>";
      print(message);
    }
  }

  counter = 0;
      }while(reply !== 'quit')