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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Mahfuzur Rahman](https://secure.gravatar.com/avatar/a98e72678a5bd68408e3498afbd99ead?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Mahfuzur Rahman
3,204 Pointsbrowser crashes while running
var students = [ { name: 'Natalie', track: 'iOS', achievments: 34, points: 57474 }, { name: 'Rudy', track: 'Web Design', achievments: 65, points: 4848 }, { name: 'Buffy', track: 'Front-end Develpoment', achievments: 23, points: 9292 }, { name: 'Stanley', track: 'Java', achievments: 94, points: 5858585 }, { name:'Bobby', track: 'HTML/ CSS', achievments: 56, points: 5755 } ];
for (var i = 0; i < students.length; i++) { for (var prop in students[i]) { document.write(prop, ': ', students[i][prop] + '<br>'); } document.write('<br>'); var search=prompt('which student you want to look up for?'); while(search===students[i].name) {document.write(prop, ': ', students[i][prop]+'<br>'); } }
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsYour code contains an infinite loop in the last few lines:
while (search === students[i].name) {
document.write(prop, ": ", students[i][prop] + "<br>");
}
Assuming the condition allows the loop to start, neither term is changed inside the loop, so the loop will continue indefinitely.
I would guess that this condition was intended to be for an "if" instead of a loop, and that it was also intended to enclose the loop that would output different properties which occurs a few lines before.
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsProceed ahead to the next video where you will see an example that answers your second question.
Just be aware that most browsers will not display anything until after you quit the program. See the "important update" in the Teacher's Notes section.
![Mahfuzur Rahman](https://secure.gravatar.com/avatar/a98e72678a5bd68408e3498afbd99ead?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Mahfuzur Rahman
3,204 PointsYeah, I have just finished watching the solution. while (true) {} was completely out of my mind. Thanks a lot.
Mahfuzur Rahman
3,204 PointsMahfuzur Rahman
3,204 PointsMany thanks Steven Parker. Now it works but only once. How can I use the search variable to run continuously? Help will be appreciated. var search = prompt('which student you want to look up for?');
for (var i = 0; i < students.length; i++) { if (search === students[i].name) {
} else if (search === 'quit') {
document.write('You have finished searching');
} }