Using Objects for Lookups **STUCK**

Tell us what’s happening:
Confused as to why I can’t pass this exercise. Is it a problem with my syntax?

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
return result;
}

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

Your browser information:

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

Challenge: Using Objects for Lookups

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups

You need to do what the exercise asks for: Use it to look up val and assign the associated string to the result variable.
You assigned results an empty string and you left it like that so it returns an empty string. The exercise wants you to use val which is "charlie" for example to access your data in the lookup object using val parameter and assign that value to result.

1 Like