Hi guys,
I was trying to solve Profile Lookup with something like this:
function lookUpProfile(name, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (name === contacts[i]["firstName"] && contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
else if (name !== contacts[i]["firstName"]) {
return "No such contact"
}
else {
return "No such property"
}
}
// Only change code above this line
}
But it did not pass. Eventually, I looked at the hint telling me to nest my if statements, but I still don’t understand why the code above did not work. Anybody can explain?