I need help to figure out why my code does not work in Javascript

// Setup 
function phoneticLookup(val) {
  let result = "";

  // Only change code below this line
  val 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");

Heres The link to the question I was trying to answer with that code above. Basic JavaScript: Using Objects for Lookups | freeCodeCamp.orgLink to the question I was trying to answer with my code posted.

Can you be more specific about what is going wrong?

You should be getting an error because of this line

way does. val lookup = { in my code bring out a error in my code in how do I fix it.

Is val the keyword to declare a variable? You are looking for let or const

way does. val lookup = {

in my code bring out a error in my code, in how do I fix it.

Convert the switch statement into an object called lookup. Use it to look up val and assign the associated string to the result variable. Thats what the task says do so I think so.

Did you read what I wrote? I told you what is wrong with it.

You cannot use val to declare a variable.

This doesn’t say to use val as a variable declaration keyword. Using val in that way is not valid code.

can you show me because I don’t know.

I will let you know if that work or not when try it out.

I just change val to const. It work I will be putting this in my notes.

In the instruction video val was used to declare a variable that was a object in it work. Can that be explained?

Tips on how you were able to Rember The basics please.

I miss read the video it was not val as I thought it was var.

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