Im kinda confused how the profile lookup solution works
So this was my intial code
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";
}
}else{
return "No such contact";
}
}
However the correct way of doing it is putting the return “No such contact” outside of the for loop. Could someone explain to be how the loop works in this instance because i was thinking how can the return be outside when the whole loop is already iterated and were out of it.