I cannot pass the test of “Profile Lookup”.
/* my code is below*/
function lookUpProfile(firstName, prop){
var i;
for (i = 0; i < contacts.length; i++ ){
if( contacts[i].firstName === firstName)
if(contacts[i].hasOwnProperty(prop))
return contacts[i].prop;
else
return "No such property";
}
if( i == contacts.length)
return "No such contact";
}
Link to the challenge:
please help me to fix the bug.Thks!