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

Atıl Kurtulmuş
4,945 PointsYou can't loop prompt and print like shown in the video.
I don't think my code is wrong because in the loop the function needs to print to the page before asking for another prompt but in the video browser writes to the page after each prompt. What is wrong ?
function capFirstLetter(str) {
str = (str[0]).toUpperCase() + str.substr(1);
return str
}
function stuSearch(aray, str) {
var html = "";
for (var obj in aray) {
if ( str.toUpperCase() == (aray[obj].name).toUpperCase()) {
for ( var prop in aray[obj]) {
if ( prop == "name") {
html += "<p><strong>" + capFirstLetter(prop) + ": "+(aray[obj])[prop] + "</strong></p>";
} else {
html += "<p>" + capFirstLetter(prop) + ": "+(aray[obj])[prop] + "</p>";
}
}
}
}
print(html);
}
do {
str = prompt("Enter student name");
stuSearch(students, str);
}while(str != "quit")
2 Answers

andren
28,558 PointsYou are correct. The behavior shown in the video is no longer possible while using a modern browser. There is a note about that fact in the Teacher's Notes of the video:
Important Update
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.
So this is not caused by a fault in your code.

Anas AlHariri
8,776 PointsYou still can have it the same like in the video, and that by using Firefox browser. I noticed that when I was using Google Chrome then I tried with Mozilla Firefox. The Google Chrome didn't print it right away, but the Mozilla Firefox did! So, you may use Firefox for exact same experience ;)
best wishes.
Atıl Kurtulmuş
4,945 PointsAtıl Kurtulmuş
4,945 PointsOh I've completely missed it. Thanks for your notice