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

Tibor Ruzinyi
Tibor Ruzinyi
17,968 Points

Code not working: Unexpected identifier

Hello all, I am trying to do this challange but my code is not woking. Do somebody know where i did mistake ?

     var loppThruNames = function(students) {
    for(var i = 0; i < students.length ; i++){
        var promptname = prompt("Type Name");          
        if students[i].Name === promptname{
          print(students[i].Name + students[i].Track)
        }else if{
          print("Sorry Student not found");
        }else{
          if promptname.toLowerCase === 'quit'{
            break;
          }
        }
    }
  }

  loopThruNames(students);       
            ```

5 Answers

Hi Tibor,

One thing I noticed is your loops are not correct syntax.

Your one is currently setup like

 if students[i].Name === promptname{
          print(students[i].Name + students[i].Track)

But if's need to be like this

if(students[i].Name === promptname) {
print(students[i].Name + students[i].Track)
}

You just missed the brackets around your condition.

Hope that helps.

you've got a typo in var loopthoughnames

and now so have i ;)

Tibor Ruzinyi
Tibor Ruzinyi
17,968 Points

hahaha thx , ive repaired the typo but it still says : Uncaught SyntaxError: Unexpected identifier

Tibor Ruzinyi
Tibor Ruzinyi
17,968 Points

Thank you very much guys for your help