Basic javascript. Profile Lookup

Basic javascript. Profile Lookup
0

#1

Tell us what’s happening:
Please help me to know where I’m getting this challenge wrong.

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 contacts";
// 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 (Linux; Android 7.0; Infinix X5010 Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.137 Mobile Safari/537.36.

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


#2

You have a argument “name” in your function.
You have not used it anywhere in your function.
Try to figure out how you have to use it.

One more thing, here it should be contact not contacts.

Does this help?