Basic JavaScript: Profile Lookup Help!

This challenge is driving my crazy. Any help with it will be much appreciated.

This is what I got:

function lookUpProfile(name, prop){
var i=0;
while (i > contacts.length) {
    if (contacts[i]["firstName"] === name) {
        var j = 0;
        while  (j < contacts.length) {
        if (contacts[j].hasOwnProperty(prop)) {
            return contacts[j][prop];
          }
          j++;
          return "No such property"
        }
    } 
    i++;
}
return "No such contact"
}

Thank you!

One issue that I see is that there is no variable named “contacts”, so your while loop never executes, and goes straight to your return statement of “No such contact”.

this while loop will never execute.

1 Like

Yes, you’re right. I removed that second loop and it works now.

Thank you!