gotStuck on Profile Lookup

Hello freeCodeCampers! I am trying to do the Profile Lookup but I am not able to do so.

Any help would be very much appreciate it.

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 h = 0; h < contacts.length; h++){
    if(contacts[h].firstName === firstName){
        if(contacts[h].hasOwnProperty(prop)){
            return contacts[h][prop];
        }else{
            return "No such contact";
        }
    }
}
return "No such property";
// 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

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

One error I can see is with this line.

You will need to compare with string of “firstName” instead of just firstName. But is this really necessary? They all have firstName property anyways :slight_smile:

Adding to what @shimphillip said,

You have this name argument in your function and you are not using it anywhere in your code.
Also, what i noticed is:

This should be “No such property”.
Same goes for “No such contact”.
Hope this helps.