Using Objects for Lookups hurr?

Tell us what’s happening:
I think there is something wrong with this exercise. I finally give up after a day and go to the solution page. Turn out the solution code is exactly like mine. I even double check it by copy-paste the solution code but it didn’t work either.

Your code so far


// Setup
function phoneticLookup(val) {
  var result = lookup[val];

  // Only change code below this line
  var lookup = {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank"
  };
  // Only change code above this line
  return result;
  
}
phoneticLookup("charlie")
// Change this value to test

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36.

Link to the challenge:

You are using the object lookup before defining it, so your result has actually value of undefined

2 Likes

Oh I am such a dumbass. Thanks for responding!

You’re not :slight_smile: do not worry, even the best programmer can miss something like that. We’re help to help

1 Like