Using Objects for Lookups Where's My Error?

Tell us what’s happening:

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"
  // Only change code above this line
  return result;

// Change this value to test

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36.

Link to the challenge:

So, the function initially sets result to empty quotes. You’ve got a lookup table, yep, and then you return result… which is still empty quotes.

If your function has been passed a parameter, val, which indicates the property name of an object (lookup, in this case), how can we set result to contain the value in that property?

result = lookup[val];


1 Like

Bam-boom. Done. Very nicely figured. Keep up the great work, and keep asking the questions! :wink: