I’m confuse about the process of having contacts[x].firstName instead. Could someone explain it in more details?
function lookUpProfile(name, prop){
// Only change code below this line
for (var x = 0; x < contacts.length; x++){
if (contacts.firstName === name) {
if (contact.hasOwnProperty(prop)) {
return contacts.firstName[prop];
} else {
return "No such property";
}
}
}
return "No such contact";
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.