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

This code doesn't seem to work

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Students</title> <link rel="stylesheet" href="styles.css"> </head> <body >

<div id = "output"></div> <script src = "student.js"></script> <script src = "studentscript.js"></script>

</body> </html>

var students = [ {

Name: "Dave", 
Track: "Front end Development", 
Achievements: 300, 
Points: 14000

}, {

Name: "Graham", 
Track: "IOS Development with swift",
Achievements: 175, 
Points: 10000

}, {

Name: "Steven", 
Track: "PHP Development", 
Achievements: 200, 
Points: 900

}, {

Name: "Rachel", 
Track: "Android", 
Achievements: 450,
Points: 20000

}, {

Name: "George", 
Track: "PHP", 
Achievements: 450,
Points: 20000



var message = ""; var student; var search;

function print(message){

 document.getElementById("output").innerHTML = message;


function getStudentReport(student){

    var report ="<h2>Student: " + student.Name + "</h2>";
    report +="<p>Track: " + student.Track + "</p>";
    report +="<p>Points: " + student.Points + "</p>";
    report +="<p>Achievement: " + student.Achievements + "</p>";
    return report;


search = prompt("Search student records: Type the name [Jody] (or type quit to end)"); if(search === null || search.toLowerCase() === "quit"){ break; }

    for(var i = 0; i <students.length; i++){

        student = students[i];
        if(student.Name === search){
            message = getStudentReport(student);



3 Answers

Steven Parker
Steven Parker
230,024 Points

Proper code quoting would help tremendously. See the Markdown Cheatsheet pop-up below the answer section. :arrow_heading_down:

But I was able to try your code anyway, and it works very well. Good job! :+1:

Now, why do you think it's not working? Did you try to enter names in lower case? Since you don't do any case conversion, it's important to enter the student name with proper capitalization. Or are you having a different problem?

Are you not getting any output in the web browser? If so, I think your issue is with linking your scripts. It should look like this.

  <script src="js/students.js"></script>
  <script src="js/student_report.js"></script>

students.js and student_report.js are nested inside the js folder directory so without specifying that you probably won't get any output because it cannot find those files.

also maybe the way you have your print function setup, not sure. Here's mine

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