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 trialdebasis nath
11,650 PointsThis code is not working except the "quit" part ; But I'm getting the message printed out unless I cancel.
var students = [ { name : "debasis",track : "jaascript",achivement : "4" ,points : "5499"}, { name : "kishan",track : "python",achivement : "3" ,points : "1422"}, { name : "soraj",track : "html",achivement : "8" ,points : "3022"}, { name : "ashish",track : "Ajax",achivement : "2" ,points : "3222"}, { name : "neha",track : "css",achivement : "9" ,points : "13422"}, ]; var student; var message;
function print(message) { var div = document.getElementById('output'); div.innerHTML = message;
} function getReport(student){
var report = "<h1> Student: "+student.name +"</h1>";
report += "<p> track: "+student.track +"</p>";
report += "<p> achivement: "+student.achivement+"</p>";
report += "<p> points: "+student.points +"</p>";
return report;
}
while(true){ var response = prompt("Name of the student you want to search for ? or Enter 'Q or q' to quit"); for(var i = 0; i < students.length ; i+=1){ student = students[i];
if(student.name === response){
message = getReport(student);
print(message);
}
}
if(response.toLowerCase() === "q" ){
print("bye");
break;
}
}
1 Answer
Steven Parker
231,275 PointsIf I'm interpreting you correctly, what you describe is normal.
Please read the "Important Update" under the "Teacher's Notes" on the video page.
debasis nath
11,650 Pointsdebasis nath
11,650 Pointsyeah, I read it But I want it to be printed out on the page once it matches a name. Is there any way to do that?
Steven Parker
231,275 PointsSteven Parker
231,275 PointsOnly when you "quit". You'll learn other ways to to do output later that will not have this restriction.