"profile lookup"- need more details

Link to challenge: https://www.freecodecamp.org/challenges/profile-lookup

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.

Note: Backticks are not single quotes.

markdown_Forums

contacts is not an object with a property named firstName.

Could you explain it in more detail? doesn’t the set up make contacts an object?

The setup makes contacts an array. Each element of the array is an object which you might access by contacts[i], and each has a .firstName property.

I understand.Thank you!