Using Objects for Lookups - Instruction Error

Using Objects for Lookups - Instruction Error
0

#1

Tell us what’s happening:

For some reason the instruction “You should not use case, switch, or if statements” is wrong. Can anyone help me out here and tell me what my error might be?

EDIT: Fixed my error, needed to remove the list already there, not comment it out.

Your code so far

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

  // Only change code below this line
  /*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";
  }*/
  
  var lookup = {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank"
  };
  
  result = lookup[val];

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

// Change this value to test
phoneticLookup("charlie");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36.

Link to the challenge:


#2

The reason it was giving you the error, is the test behind-the-scenes was looking for keywords such as “if”, “case”, and “else”, even though the text was commented. You figured it out on your own though, so that is good.