Hey all, just finished my code and this is what I came up with, but not sure why or if i did this right with the if/else statement on the outside of the other if/else statement. Something is wrong with the last else. Can someone please take a look at this code and tell me whats wrong with it? thanks a bunch
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(firstName, prop){
// Only change code below this line
for (i=0; i < contacts.length; i++) {
for(j=0; j < contacts[i].length; j++){
if (contacts.firstName === firstName){
console.log(firstName);
if (prop === contacts.lastName) {
return contacts.lastName;
}
else if (prop === contacts.number) {
return contacts.number;
}
else if (prop === contacts.likes) {
return contacts.likes;
}
else {
return "No such property";
}
}
}
else {
return "No such contact";
}
}
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");