I need help with Using Objects for Lookups

I need help with Using Objects for Lookups
0

#1

// 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”);


#2

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


#3

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,


#4

alright i will try that, thanks.


#5

alright i will get on it please. Thanks.