Hey, I was wondering why bracket notation works for the situation below, when reassigning result to the lookUp object. However if I use Dot notation, the code does not work.
You can find the challenge here:
// Setup
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"
};
result = lookUp[val];
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("charlie");
To be more specific. I am talking about bracket notation
result = lookUp[val];
vs dot notation
result = lookUp.val;
and why dot notation does not work for the challenge. At Least the way I implemented it.