Why it returned like this contacts[x][prop] ?
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
];
function lookUpProfile(name, prop) {
for (var x = 0; x < contacts.length; x++) {
if (name === contacts[x].firstName) {
if (contacts[x].hasOwnProperty(prop)) {
return contacts[x][prop];
} else {
return "No such property";
}
}
}
return "No such contact";
}
// Change these values to test your function
console.log(lookUpProfile("Akira", "likes"));
****
I know all other codes, but why it returned the prop var and x like a two dimensional array?