val contains the argument passed in from the phoneticLookup function. In this example, “charlie” is passed into the variable val.
There are two ways to get the value of a specific object property. One is using dot notation. If I wanted to get the value of of property “echo” in the lookup object using dot notation, I would write lookup.echo
The other way to get the value of a specific object property is to use bracket notation. There are two times you absolutely must use bracket notation. The first time is if the property name has a space in it. For example, if the lookup object would have had a property called “fox trot” instead of “foxtrot”, then to get the value of “fox trot”, you would have to write lookup[“fox trot”]. The second time you would have to use bracket notation is if you are using a variable for the property name. In your example, since val is a variable which contains the value “charlie”, we have to write lookup[val] to get the “Chicago” value.
Hopefully this clears up any misunderstanding. If not, ask more questions.