Can someone explain to me how result = lookup[val] associates the I believe element of the function phoeneticLookup to the object properties in lookup? I was under the assumption brackets call up a property of the object? I assumed lookup[val] would be trying to find the property down under lookup called val.
I’m on my second round through the js course, but this really isnt making sense to me. I’m just looking for some explanation on how this works. I probably need to go over the rest another 10 times and supplement a lot of this to really get a grasp of it.
Tell us what’s happening:
Describe your issue in detail here.
Your code so far
// Setup
function phoneticLookup(val) {
let result = "";
// Only change code below this line
const lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
}
result = lookup[val]
// Only change code above this line
return result;
}
phoneticLookup("charlie");