Hi, please I would like some to explain to me why dot notation didn’t work in the programme below:
function phoneticLookup(val) {
var result = “”;
var lookup = {
alpha: “Adams”,
bravo: “Boston”,
charlie: “Chicago”,
delta: “Denver”,
echo: “Easy”,
foxtrot: “Frank”
};
result = lookup.val;
// Only change code above this line
return result;
}
But using writing result = lookup[val]; gave the desired result. I would like to know if there is any important difference between the two type of notations, which is responsible for this result.