Basic JavaScript - Using Objects for Lookups

Hello guys, I have a little issue.
I am currently doing the freeCodeCamp course and am at JavaScript for Lookup
Normally I think my code should pass through the tests but unfortunately I don’t know what is wrong. Probably someone can help

My code so far

// Setup
function phoneticLookup(val) {
  let result = "";

  // Only change code below this line
  const lookup = {
    "alpha": "Adams",
    "bravo": "Boston",
    "charlie": "Chicago",
    "delta": "Denver",
    "echo": "Easy",
    "foxtrot": "Frank"

result = lookup.val;
  // Only change code above this line
  return result;


Challenge: Basic JavaScript - Using Objects for Lookups

Link to the challenge:

do not use the dot notation use the [] notation instead when you assign the result variable because the val is definitely going to be a string. Let’s say it is equal “echo” so the result will be

result = lookup."echo"

well, the previous code will send an error to the console but if you do it like this

result = lookup["echo"]

this will work fine

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.