Please guys what is wrong with my codes: Using Objects for Lookups

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
   result = lookup [val];

// Change this value to test

Your browser information:

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

Link to the challenge:

Looks perfect except you don’t need to put the keys in quotation marks :blush:
You also want to return result at the end, however you could just use

return lookup.val

1 Like

There a some improvements:

  • The last item in the lookup ends with a comma, you can remove it.
  • Nothing is being returned in the function. You need to have somewhere return result;.
  • There is a comma between lookup and [val]; Why?
  • You should not change the code after the comment // Only change code above this line
1 Like

am still having the issue, after removing quotation mark:

 var lookup = {
    alpha: "Adams",
    bravo:  "Boston",
    charlie: "Chicago",
    delta:  "Denver",
    echo:  "Easy",
    foxtrot:  "Frank"

Have you got the return statement in there?

return lookup.val

1 Like

thanks a lot I has pass the test. I miss out on the return statement. Thank you for your time.

In the future a “linter” can help you catch simple mistakes like some of the ones you made above:

You can also install these linters in your editor, very handy.

1 Like

wow, I’ll check it out, thanks I really appreciate.

1 Like