Using Objects for Lookups, I'm Lost

Using Objects for Lookups, I'm Lost
0

#1

Tell us what’s happening:
I’m lost

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
phoneticLookup("charlie");

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups


#2

you seem to have created ‘lookup’ properly but you haven’t complete the rest of the instructions which say:

Use it to look up val and assign the associated string to the result variable.

So for eg. if you wanted to lookup ‘delta’ you would write
lookup.delta
and it would give you ‘Denver’ right?

How about if you want to look up the variable val ? (whatever is in there will match something in the lookup, and you need to return whatever it is that got matched)


#3

Well you created a lookup object. That is a good first step. Now how do you reference specific properties within the object if are given a variable val which contains a property name? You have already learned how to do this in a previous challenge.