Hi guys,
I’m doing the Profile Lookup Function right now. Where you have to find contacts in an json object.
Here is my code so far:
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if(contacts[i].hasOwnProperty(prop) && (contacts[i].firstName === firstName)) {
return contacts[i].prop;
} else if(!(contacts[i].hasOwnProperty(prop))) {
return "No such property";
}
}
return "No such contact";
// Only change code above this line
}
In the screenshot you can see the output (none) and the test cases (just 2 passes).
Why are the other tests not passing? In my mind that function makes perfect sense. What did I do wrong?
Thanks guys!