Basic JavaScript - Using Objects for Lookups

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
let 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");


I only want to ask what this 👉🏾result = lookup[val]; does 
Like what does it display?

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 11; TECNO KF6i) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.87 Mobile Safari/537.36

Challenge: Basic JavaScript - Using Objects for Lookups

Link to the challenge:

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

I am asking what this line of code :point_right:t5:result = lookup[val]; does
Like what does it return when the whole code is run?

Inside the function phoneticLookup there is the variable lookup that is being assigned an object with some key/value pairs, and the function is being called with the argument 'charlie'. You should have already done the portion talking about accessing values in objects properties with dot and bracket notation just a few tests back. So if you typed lookup[val] (‘charlie’ would be stored in val) what do you think the value would be based on what is in the lookup object?

1 Like