Can someone please explain the solution to this problem? I don’t understand why I have to put return “No such contact”; on the outside of the for loop and not with it. Here is my code:
function lookUpProfile(name, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++) {
if(name === contacts[i].firstName){
return contacts[i][prop] || “No such property”;
}
}
return “No such contact”;
}