Could not run the code

I am doing the challenges of:

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

Wondering why it does not work when i use hasOwnProp function in both if statement.


Here is your problem. This is checking whether the contacts have properties matching the value of the firstName variable. None of the contacts will have a property of "Harry" or "Sherlock" etc.

Ok, iI get my problem now, so the hasOwnProperty() function cannot check the property’s value but only can check if that property name exist in an object…

Thanks so much for the helpings!