Basic JavaScript - Using Objects for Lookups

Tell us what’s happening:
Describe your issue in detail here.

It keeps saying there is a syntax error and I’m very confused

  **Your code so far**
// Setup
function phoneticLookup(val) {
let result = "";

// Only change code below this line
switch(val) {
  "alpha": = "Adams",
  "bravo": = "Boston",
  "charlie": = "Chicago",
   "delta": = "Denver",
   "echo": = "Easy",
   "foxtrot": = "Frank",
};

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

phoneticLookup("charlie");
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Using Objects for Lookups

Link to the challenge:

That’s not a valid switch statement. You’ve combined elements from the switch and the lookup object.

1 Like

This is not valid syntax. You need something on the left if you are going to use =

What do you want to set equal to “Adams”?

Create your object first, with all your values. Then build the switch statement, separately.

[addendum - ignore this advice, I wasn’t focussed on the actual problem presented, follow Jeremy’s direction]

1 Like

I want to set alpha equal to Adams

No, you do not want to set alpha equal to "Adams". That is not what the instructions are saying.

  switch(val) {
    case "alpha":
      result = "Adams";
      break;
    case "bravo":
      result = "Boston";
      break;
    case "charlie":
      result = "Chicago";
      break;
    case "delta":
      result = "Denver";
      break;
    case "echo":
      result = "Easy";
      break;
    case "foxtrot":
      result = "Frank";
  }

This is the original code. You need to completely remove the switch syntax and use an object instead.

2 Likes

Sorry, so excuse my advice - I was just thinking about the problem. Let me amend that…