Hi,
I’ve been struggling with figuring out why my solution isn’t clearing all the tests. It won’t pass the final test. Even though when I look at my console log, it is testing as “No such property.” Any help would be appreciated.
Thanks!
function lookUpProfile(name, prop){
// Only change code below this line
var checkName = true;
var checkProp = true;
for (var i = 0; i < contacts.length; i++) {
if ((name === contacts[i]["firstName"]) && (contacts[i].hasOwnProperty(prop))) {
console.log(contacts[i][prop])
return contacts[i][prop];
} else if (name !== contacts[i]["firstName"]) {
console.log("No such contact");
checkName = false;
} else if (!contacts[i].hasOwnProperty(prop)) {
console.log("No such property");
checkProp = false;
}
}
if (!checkName) {
return "No such contact";
}
if (!checkProp) {
return "No such property";
}
// Only change code above this line
}
lookUpProfile("Akira", "address");