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[value];

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

phoneticLookup("charlie");


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0

Challenge: Basic JavaScript - Using Objects for Lookups

Link to the challenge:

Hi everyone!

please I don’t really know what is wrong with code and am getting confused.
please can anyone help me out figure out my error(s) out?

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[value];

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

phoneticLookup("charlie");

Do you get an error here?

yes.

I’ve tried every option

What does the error say?

ReferenceError: value is not defined

Ok, so it’s telling you that you haven’t defined value. Where is value coming from?

the value here is chicago

No, I meant, where is the variable called value defined? You cannot use variables without defining them somewhere (either in code, using let or const, or by using them in the arguments of the function)

1 Like

I don’t understand what you please

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.