Tell us what’s happening:
Describe your issue in detail here.
Your code so far
function lookUpProfile(name, prop) {
for (let x = 0; x < contacts.length; x++) {
if (contacts.firstName === name) {
if (contacts.hasOwnProperty(prop)) {
return contacts[prop];
} else {
return “No such property”;
}
}
}
return “No such contact”;
}
i does not want to work
function lookUpProfile(name, prop) {
for (let i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === name) {
if (prop in contacts[i]) {
return contacts[i][prop];
} else {
return "No such property";
}
}
}
return "No such contact";
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Profile Lookup
Link to the challenge: