Using Objects for Look-ups

I can’t see where I’ve gone wrong, can someone help please?

// 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”
};
result = lookup[“val”];

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

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

val is a variable, not a string.

1 Like

You’re really close, lookup[“val”] would search for “val” in your object, but you want to search for a variable.

1 Like