I looked up the hints and they’re both not working so I’ve looked at what other users have entered and it’s still not passing all tests. I’ve got it to where "Bob", "number"
returns “No such contact” and "Akira", "address"
returns “No such property” but the rest of the tests fail.
What am I doing wrong?!
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 x = 0; x < contacts.length - 1; x++) {
if (name == contacts[x].firstName && contacts[x].hasOwnProperty(prop)) {
return contacts[x][prop];
} else if (contacts[x].hasOwnProperty(prop) == false) {
return "No such property";
}
return "No such contact";
}
// Only change code above this line
}
lookUpProfile("Akira", "likes");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0
.
Challenge: Profile Lookup
Link to the challenge: