Profile Lookup it this the correct way?

Tell us what’s happening:

Your code so far


//Setup
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 === firstName) {
            if(contacts[i].hasOwnProperty(prop)) {
            return contacts[i](prop);    
            } else{
                return "No such property" ;
            }
        }
    }
    return "No such contact" ;
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/profile-lookup

Hey @ian,
You are very close to the solution.
You have argument name in your function and you do not use it anywhere in the function.
See if you can find how you will use it and reach the solution.
Also,

This is not the right way to access an object’s property.
All the best.

It come back with this.firstName is not defined

Could you post the new code that you have tried?

for (var i = 0 ; i < contacts.length ; i++){
if (contacts[i].firstName === firstName){
if(contacts[i].hasOwnProperty(prop)){
return contactsi;
} else{
return “No such property” ;
}
}
}
return “No such contacts” ;
// Only change code above this line
}

Look at this line carefully.
You do not have any variable named firstName with
which you are comparing contacts[i].firstName in your code.

Also, You have argument name in your function and you do not use it anywhere in the function.

See if that helps.