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

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects The Student Record Search Challenge Solution

Can't figure out why my code doesn't work. Can you help?

```var students=[ {name:'George',track:'iOs',achievements:15, points: 50}, {name:'Adam',track:'Android',achievements:30, points: 84}, {name:'James',track:'HTML',achievements:48, points: 105}, {name:'Daniel',track:'JavaScript',achievements:52, points: 143}, {name:'Marc',track:'Ruby',achievements:67, points: 167}, ];

var student=''; var selected='';

function print(message) { var outputDiv = document.getElementById('output'); outputDiv.innerHTML = message; }

function getStudentReport (student) { var report = '<h2>Student: ' + student.name + '</h2>'; report += '<p>Track: ' + student.track + '</p>'; report += '<p>Achievements: ' + student.achievements + '</p>'; report += '<p>Points: ' + student.points + '</p>'; return report;

}

while (true) { selected=prompt("Type in a student's name to see his/her records. Type 'quit' when you are done."); if (selected === null || selected.toLowerCase === 'quit') { break; } for (var i=0; i < students.length; i +=1) { student=students[i]; if (selected === student.name) { message = getStudentReport; print(message); } } } ```

1 Answer

Steven Parker
Steven Parker
231,007 Points

You must use parentheses when you call a method or function.

This is true if it needs any parameters or not. So where you have "selected.toLowerCase", it should be "selected.toLowerCase()". Even more importantly, getStudentReport requires a parameter, so when you call it to assign message, it should be like this: "getStudentReport(student)"

You may still have some work to do yet so you can display multiple students, but this should get you going again.


When quoting code, be sure the three apostrophes ("backticks") are on lines by themselves. The first set can include the language (in this case: ```js ).