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 trialjerome moore
5,005 PointsI am having an issue. I get my div etc. to print out, but I always get a weird [object Object] printout on top.
var message = '';
var student;
var search;
function print(message){
var outputDiv = document.getElementById('output');
outputDiv.innerHTML = message;
}
function record(message){
message += '<h2> Student: ' + student.name + '<h2>';
message += '<h3> Course of Study: ' + student.track + '<h3>';
return message;
}
while(true){
search = prompt('Search student database: quit to exit');
if (search === null || search === 'quit'){
break;
}
for (var i = 0; i < students.length; i++) {
student = students[i];
if (search === student.name){
//console.log(student);
mess = record(student);
print(mess);
}
}
}
1 Answer
Steven Parker
231,533 PointsYour record function takes message as an argument, and appends to it. But when you call it, you pass it a student object. That's the "object" it shows first.
Did you mean to define your function to take a student as the argument? Like: function record(student)
jerome moore
5,005 Pointsjerome moore
5,005 PointsI am upset that I missed that. Thank you.