Using Objects for Lookups - help

Hey, I encountered a problem there is a simple exercise, but I’m not sure that my logic is correct.
anyone could me help ?

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"
  var value = val;
  result += lookup[value];
  // Only change code above this line
  return result;

// Change this value to test

But still when I call function with empty string parameter. test shouts phoneticLookup("") should equal undefined

Use = not +=, you’re trying to add undefined to a string, so your function will error rather than just returning undefined

Yes it solved, I saw the previous topic with the same problem> Thanks a lot for your reply. :slight_smile:

1 Like