Basic JavaScript: Using Objects for Lookups,help me

// 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
  return lookup[val];
}

// Change this value to test
phoneticLookup("delta");

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums

1 Like

// 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
return lookup[val];
}
// Change this value to test
phoneticLookup(“delta”);

sir please correct the code and paste it here…plz

Done sir thnx alot…:smile::smile::smile::smile: