I’m stuck on the first execution of the if statement. Not sure the other ones correct but I know the first part isn’t. I’m struggling a little bit to figure out how you pick out the specific prop of the name that has been chosen in the parameter if you know what I mean like getting Akira’s ‘likes’.
//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++) {
for (var j=0; j < contacts[i].length; j++) {
if (contacts[i][j].hasOwnProperty(name) && contacts[i][j].hasOwnProperty(prop)) {
???
} else if (contacts[i][j].hasOwnProperty(name) === false) {
return "No such contact";
} else {
return "No such property";
}
}
}
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/profile-lookup