Using Objects for Lookups, my code isn't running please help

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"
  result = lookup.val;
  // Only change code above this line
  return result;
// Change this value to test
1 Like

You object doesn’t have a property called "val", so it returns undefined. When you have a variable you can’t use dot notation, you need bracket notation

You can read for example here for the lengthy explanation:


Thank you so much! This was very helpful and I now get what I was doing wrong, Thank you!!