Profile Lookup w/ dot vs. bracket

Ok, question about dot versus bracket notation in this challenge.

return contacts[i].prop; does not work while return contacts[i][prop]; does.

We’re IN the array, hence the contacts[i]. This finds the “i” item in the array, which is an object. Because I’m now in an object, dot notation should work. It actually works in my if statement where if (firstName == contacts[i].firstName).

Is this a flaw in the challenge (i.e. would work in the real world)? If not, can someone please explain what I’m missing. Thanks!

As reference, code that doesn’t work:

function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
if (firstName == contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i].prop;
} else {
return “No such property”;
}
}
} return “No such contact”;
// Only change code above this line
}

Code that DOES work:

function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
if (firstName == contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return “No such property”;
}
}
} return “No such contact”;
// Only change code above this line
}