Profile Lookup: Need help understanding why my solution doesn't work

Hi.

I already saw the solution and understand it. I just don’t understand why my code doesn’t work.
The only problem is when it doesn’t have the property.

function lookUpProfile(name, prop){
// Only change code below this line
  for(var i = 0; i < contacts.length; i++) {
    if(name === contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    } else if(name === contacts[i].firtName && contacts[i].hasOwnProperty(prop) === false) {
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}

The first thing I see is that there is a typo here, contacts[i].firtName

1 Like

damm…i can’t believe it. Thank you :slight_smile: i’ve been messing my head trying to understand why it didn’t work, and didn’t even consider that.