Hi, I can’t understand where I am going wrong with the code. Need help please. I am stuck.
function lookUpProfile(name, prop) {
for (let i = 0; i < contacts.length ; i++){
if (name == contacts[i].firstName && contacts[i].hasOwnProperty(prop)== true){
return contacts[i].lasName;
} else if (contacts[i].hasOwnProperty(prop) == false){
return "No such property."
}
else if (name !== contacts[i].firstName) {
return "No such contact."
}
}
}
You need to first fix your code so it goes through the entire array and checks for that first name. If that name does exist, then you check if the prop exists.
If we go through the entire array and that name does not exist then you return “No such contact”
Hope that makes sense!
Once you fix that part of the logic, then you have a few small errors here