Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Alexandra Wakefield
Alexandra Wakefield
1,866 Points

I'm So Confused

While doing this challenge, I am running into all sorts of problems.

For one, it's like the if statement within the for loop is being ignored when it comes to breaking out of the while loop. I've tried break, false, and even making an outside variable equaling true so I can change it to false if the if statement happens. However, it obviously works because the html variable prints to the page.

Two, I have no idea where or how to add alert("Sorry, this name is unavailable") to where it works properly. It either shows up no matter what I put in, creates an endless loop, or shows up until the for loop either completes or has a chance to repeat.

I'm lost.

Here's what I have currently:

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

var html = "";

function studentReport() {
  while(true) {
    var studentRequest = prompt("Please enter the student's fullname below or \"quit\" to exit.");
    var studentName = studentRequest.toLowerCase();
    for(var j = 0; j < students.length; j++) {
      var student = students[j].name.toLowerCase();
      if(studentName === student) {
        html += "<b>Student: " + students[j].name + "</b>";
    if(studentRequest === "quit") {




Julian jackson
Julian jackson
6,285 Points

Hi Alexandra,

It looks like you haven't declared your "students" array globally or within your function but it's called for in your for loop? not sure if that helps.


1 Answer

Thomas Nilsen
Thomas Nilsen
14,957 Points

Check out these answers.

They should help you.