Using Objects for Lookups (help!)

Tell us what’s happening:
I have been stuck on this problem for the last 4 hours I am totally lost anybody got any idea how to help me solve this? cheers

Your code so far


// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line
var lookup = {
  "alpha": "Adams",
  "beta": "Boston",
  "charlie": "Chicago",
  "delta": "Denver",
  "echo": "Easy",
  "foxtrot": "Frank",
};

var phoneticLookup = lookup;
lookup = result;
  // 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/66.0.3359.181 Safari/537.36.

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

OK, two problems. First of all, you wrote “beta” instead of “bravo”.

And then what to return. You don’t need the lines:

var phoneticLookup = lookup;
lookup = result;

get rid of them.

You need to assign result. Use this new object that you created, and use the variable val as a selector to select the right property value and assign it to result. Do you know how to access an object property with a variable as the key?

Please let us know if this is not a sufficient hint.