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

Looking for a peer review for the student report challenge!

I have included my code, I watched the solution video, but figured using more functions like I did would make the code more extensible should that need arise... Thoughts?

/*****************************
********** Functions *********
******************************/


function printH2(message) {
  document.write("<h2>" + message + "</h2>");
};

function printP(message) {
  document.write("<p>" + message + "</p>");
};

function printAttributes() {
  printP("Track: " + students[student].track);
  printP("Achievements: " + students[student].achievements);
  printP("Points: " + students[student].points);  
};



/*****************************
********* Running Code *******
******************************/

while (true) {
  var search = prompt("Please enter a student name to search. Type 'quit' to exit the program.");
  if (search.toLowerCase() === 'quit') {
    break;
  } else {
    for (student in students) {
      if (search === students[student].name) {
        alert("Student found!");
        printH2(search + ": ");
        printAttributes();
      }
    }
  }
}

Thank you in advance!