Hello,
Please see below.
The last return statement is outside of IF. How come that last return statement doesn’t get executed when the first IF is true?
That last return statement “No such contact” is outside of the first IF. Shouldn’t that last return statement be executed no matter what?
function lookUpProfile(name, prop) {
for (var x = 0; x < contacts.length; x++) {
if (contacts[x].firstName === name) {
if (contacts[x].hasOwnProperty(prop)) {
return contacts[x][prop];
} else {
return "No such property";
}
}
}
return "No such contact";
}