Tell us what’s happening:
Hello there!
Sooo, I got this code here. I do not understand what is going wrong… if you know what goes wrong, could you tell me? I did look at the solutions. I get the idea but I think I miss some formalities or lack some knowledge of rules.
Thanks for your help!
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 n = 0; n < contacts.length; n++) {
if (contacts[n].firstName === name && contacts[n].hasOwnProperty(prop)){
return contacts[n][prop];}
else if (contacts[n].firstName !== name){
return "No such contact";
}
else {
return "No such property";
}
}
// Only change code above this line
}
lookUpProfile("Akira", "likes");
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0
.
Challenge: Profile Lookup
Link to the challenge: