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

Guadalupe Favela
Guadalupe Favela
5,566 Points

won't print to the page when I call the function. can someone help me with this.

var html ; var student; var message;

function getStudentReport (student){ var report = "<h2> name : "+ student.name + "</h2>"; report += "<p> track : "+ student.track + "</p>"; report += "<p> achievments : " + student.achievments + "</p>"; report += "<p> points : " + student.points + "</p>"; return report; }

function print(message){ document.write(message); } while (true){ message = prompt("name of student, press [quit] to quit"); if(message === "quit" || message == null){ break; }

}

for (var i = 0; i < students.length; i+= 1) { student = students[i]; if (student.name === message ){ html += getStudentReport(student); print(html); }

}

Elise Pitel
Elise Pitel
2,361 Points

In the teacher note they said : Since this video was shot, the behavior of most browsers has changed, so you won't see the same thing as I demonstrate in the video. In the video, you'll see that my script is able to print out to the browser using document.write( ) while inside a loop.

Most browsers no longer do that: they wait until the loop finishes and then they print to the window. So, you'll see a blank page until you type quit in the prompt window — then you'll see all the output printed to the screen.

Maybe that is the cause of your issue ? :/ Good luck!