Tell us what’s happening:
My code does pass, but my question is why does it pass only when I use bracket notation. At first, I used the dot notation and it won’t let me pass. I googled and found that they both should have work, so I’m just curious why that is. Is it a bug or is there a reason to why a dot notation will not work in this situation. Thank you for your time and help.
Your code so far
// 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");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups