JavaScript: Using Objects for Lookup

JavaScript: Using Objects for Lookup
0

#1

i honestly don’t know whats wrong with the code

// 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("bravo");

#2

can you provide a link to the challenge?


#3

also looks like you have an extra comma at the end of this line…


#4

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups


#5

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.


#6

See that comment? You were not supposed to modify the original line of code which was:

return result;

The instructions are quite specific in what you are to do:

Use it to look up val and assign the associated string to the result variable.

You have the right idea, but you just need to assign what you were returning to the result variable declared in the function, so the tests can validate you did it correctly.