function lookUpProfile(name, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === name) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return "No such property";
}
}
}
return "No such contact";
// Only change code above this line
}
Hi Everyone!
I got all the code correct the first time, except for the last line:
return "No such contact";
I was trying to put it after the outer if statementâs closing bracket like so:
function lookUpProfile(name, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === name) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return "No such property";
}
} else {
return "No such contact";
}
}
// Only change code above this line
}
I just need a bit of explanation as to why that is an error. Thanks very much!
PS. I find it hilarious that it took me almost an hour to look at the hint, to find out that everything I wrote was almost identical except for that one line. Itâs frustrating, BUT I LOVE IT!!!