// 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
let x = 0;
for (let cycle = 0; cycle < contacts.length; cycle++) {
if (name === contacts[cycle].firstName && contacts[cycle].hasOwnProperty(prop) == true) {
return contacts[cycle][prop];
} else if (name !== contacts[cycle].firstname) {
x = "No such contact";
}else if(name === contacts[cycle].firstName && contacts[cycle].hasOwnProperty(prop) == false) {
return "No such property";
}
}
return x;
}
// Only change code above this line
lookUpProfile("Akira", "likes");
change contacts[cycle].firstname
to contacts[cycle].firstName
in the else if
condition. You mistakenly used a lowercase “n” in firstname
instead of an uppercase “N”.
1 Like
You just had a typo error on your 1st else if statement. Specifically on calling the parameter of the function “firstname”. The rest of the code are great.
Have a great day!
1 Like
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.