Basic JavaScript - Using Objects for Lookups

Tell us what’s happening:
Hey, I am unsure where I went wrong with this code. I wrote it like the example and added it was the result. I am wondering if I must have deleted something I shouldn’t have.

Your code so far

// Setup
function phoneticLookup(val) {
  let 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;
}

phoneticLookup("charlie");

Your browser information:

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

Challenge: Basic JavaScript - Using Objects for Lookups

Link to the challenge:

1 Like

Very very small error. var lookup {...} is missing an assignment operator…

1 Like

This is what I love, this small bugs that is so hard to find when you look at code all day.

2 Likes

And the harder you look, the more you can’t find them! This is where getting fresh eyes on a project can help…

2 Likes