Profile Lookup Challenge Ifs Arrangement order

well this is awkward, i get 3 of them right and when i rearrange the if orders i get the other 3 right. I understand almost everything except im unsure of the !contacts[i].hasOwnProperty line.

Can anyone point out what exactly is wrong in my code? its driving me crazy.

function lookUpProfile(name, prop){
// Only change code below this line

    for(var i = 0; i<contacts.length;i++){
        if(contacts[i].firstName==name && contacts[i].hasOwnProperty(prop)) return contacts[i][prop];
          
        if(contacts[i].firstName!=name) return "No such contact";
          
        if(contacts[i].firstName==name && !contacts[i].hasOwnProperty(prop)) return "No such property";
          
        
            
}

Thanks, i did. your right.
edited it and it worked. Nested ifs is the key here.