My issue is detailed below.
Good lord, I’m stuck here… I don’t know what to do to return these property values. I think there’s something wrong with my code here. it seems I am at lost and tried a lot and it does not seem to have a fruitful result. I would like to see the answer elsewhere but I am afraid it will make me even dull and does not solve the issue.
I am sorry that this might be a repost, but my mind is kinda overwhelmed.
Please give me a hint or point that the code that might be the culprit
Thanks,
if (name === contacts[i].firstName && prop === contacts[i]) {
result = contacts[i][prop];
**My code below**
// Setup
const 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 (let i = 0; i < contacts.length ; i++) {
if (name === contacts[i].firstName && prop === contacts[i]) {
result = contacts[i][prop];
return result;
} else if (name !== contacts[i].firstName) {
return "No such contact";
} else if (prop !== contacts[i]) {
return "No such property";
}
}
// Only change code above this line
}
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/95.0.4638.69 Safari/537.36
Challenge: Profile Lookup
Link to the challenge: