Can you pl. help me understand what is the reason for the errors. I have commented the reason in CAPS on the particular lines.
Objects for Lookups Topic
function phoneticLookup(val) {
var result = "";
// Only change code below this line
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};
return lookup[val]; // CANNOT USE lookup.val as it gives an error. NOT ABLE TO UNDERSTAND WHY
return result;
// Only change code above this line
}
// Change this value to test
phoneticLookup("charlie");
Profile Look up
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i=0; i<contacts.length; i++)
{
if (firstName==contacts[i].firstName) /*CANNOT USE contacts[i][firstName] as it gives an error. NOT ABLE TO UNDERSTAND WHY */
{
if(contacts[i].hasOwnProperty(prop))
{
return contacts[i][prop];
}
else
{
return "No such property";
}
}
}
return "No such contact";