Basic Javascript: Profile Lookup AND statement condition

My approach was to use an AND vs a nested if but it doesn’t seem to be working. Any ideas why?

var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["JavaScript", "Gaming", "Foxes"]
    }
];


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

Interesting I didn’t think of exiting the for loop and how that related to what the real problem is asking for. I’ve updated the code to


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

and still no dice!

I think the issue is that I’m using the not (!) operator instead of the solution. I haven’t seen anyone use it yet.

contacts[i].firstName is a string, it can’t have a property
hasOwnProperty can be used on objects only