I don’t understand what I’m doing wrong here. I am passing the “No such contact” and “No such property” requirements but am failing to return the values of the properties. It should return the values in the “return contacts[x][prop];” line but it isn’t for some reason. Can somebody point out what I’m missing here?
function lookUpProfile(name, prop){
// Only change code below this line
for (var x = 0; x < contacts.length; x++) {
if (contacts[x]["firstName"] === name) {
if (contacts[x].hasOwnProperty(prop) === true) {
return contacts[x][prop];
}
else {
return "No such property";
}
}
return "No such contact";
}
}