I need help with Using Objects for Lookups

// Setup
function phoneticLookup(val) {
var result = “Charlie”;

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

lookup[“bravo”];
lookup[“charlie”];
lookup[“echo”];
lookup[“foxtrot”];
lookup[result];

// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup(“charlie”);

The quotes matters, see the difference

"alpha":"Adams"

And also,
you should use bracket notation to access the argument variable var[arg] and assign it to the result variable

1 Like

Hi,
What you are trying to do is to give your function a variable and let it look for it (as a key in the lookup object), your function should then return the result which is the value that matches the key. (object = {key: value}).
Hope this helps a little, also make sure you’re using quotes (") not backticks.
good luck,

1 Like

alright i will try that, thanks.

alright i will get on it please. Thanks.