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 trialAdam Laszlo Vincze
4,083 PointsOwn Student Record Search Challenge
Hello,
Here is my program. What do you think about it?
var search;
var data;
var result = '';
for (var i = 0; i < students.length; i++) {
data = students[i];
search = prompt("Who you want to find?");
if (search === "q" || search === null) {
break;
} else if (search === data.name) {
result += '<h1>Student Record:</h1>';
result += '<h2>Student:'+ data.name +'</h2>';
result += '<p>Skills:'+ data.track +'</p>';
result += '<p>Achievements:'+ data.achievements +'</p>';
result += '<p>Points:'+ data.points +'</p>';
break;
}
}
print (result);
1 Answer
John Forbes
10,879 Pointstwo thoughts, this will not be a continuous loop, " i < students.length" means it will end when they have searched for the students.length times.
second thought data.name is only going to look at one item in the array before it prompts again, it does not actually search the whole array of objects.