Hey All,
I am not sure I understand why the code below works.
In particular, how does the function know what value to pass through the lookup list (alpha, charlie, bravo…)? Where is it stated that val = parameter?
Very confused…
// 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",
};
return lookup[val];
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("charlie");
Link to the challenge:
https://www.freecodecamp.org/challenges/using-objects-for-lookups