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

Not sure what i am missing in this Challenge . Mentioned below is my code but nothing shows up when i run it.?

/created 5 objects in the student array with 5 properties in them.

    var students = [
  {
   Name:'jason' , 
   Track:'Ruby on Rails',
   Achievements:'Ruby, Rails, HTML, Javascript',
   Points:4000

  },
  {
   Name:'ryan' , 
   Track:'Javascript',
   Achievements:'Ruby, Rails, HTML, Javascript',
   Points:3000
  },
  {
   Name:'joel' , 
   Track:'HTML,CSS',
   Achievements:'Ruby, Rails, HTML, Javascript',
   Points:6000
  },
  {
   Name:'james' , 
   Track:'Marketing',
   Achievements:'Ruby, Rails, HTML, Javascript',
   Points:7000
  },
  {
   Name:'nathan' , 
   Track:'Javascript, Ruby, Rails',
   Achievements:'Ruby, Rails, HTML, Javascript',
   Points:10000
  }

];
//for loop which will help to print out the properties in the object

// Created 2 new variables 

    var student;
    var message = '';

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


        while(true){
        search = prompt("Please enter the name of the student whoes information you want to view. You may type 'quit' to exit ");

        search = search.tolowercases(); 

        for(var i = 0; i < students.length; i += 1){
            student = students[i];

        if (search === 'quit'){
            break;
    }   else if(student.name === search) {
            print(student[i].Name)
            print(student[i].Track)
            print(student[i].Achievements)
            print(student[i].Points) 
    }   else {
            print(search + 'is not a student with us ')
        }   
        }
        };

1 Answer

Hi Gladston,

The convention in JavaScript is to use lower-camelcase for the names of properties and methods of objects. This convention helps avoid syntax errors like the one you have above. You're asking if student.name === search but student.name doesn't exist; student.Name does exist... but it really should be renamed to student.name.