Issues with "Using Objects for Lookups"

Hey,

been doing this one, and got somehow stuck.
I know not to modify the return statement, but altering the result var somehow didn’t do it …

Ideas, anyone ?

Your code so far


// Setup
function phoneticLookup(val) {
  var result = lookup[val];
  var lookup = {
    "alpha" : "Adams",
    "bravo" : "Boston",
    "charlie" : "Chicago",
    "delta" : "Denver",
    "echo" : "Easy",
    "foxtrot" : "Frank"
  };

  // Only change code above this line
  return result;
}

// Change this value to test
phoneticLookup("delta");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

You can’t use something before you declare it, so writing lookup[val] before declaring lookup would just give you undefined

Maybe that’s not the right place to write lookup[val], is it?

1 Like

Got it man, wrote return lookup[var] below the lookup object, and it went smoothly. Thx.