Can anyone helpme Using Objects for Lookups

Can anyone helpme Using Objects for Lookups
0

#1

Tell us what’s happening:

Your code so far

// Setup
function phoneticLookup(val) {
  var result = "";
 
  // Only change code below this line
  var lookup = {
    alpha:"Adams",
    bravo:"Boston",
    charlie:"chicago",
    delta:"Denver",
    echo:"Easy",
    fortrot:"Frank"
  };
  /*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";
  }*/
result = lookup["charlie"];
  // 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 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.

Link to the challenge:


#2

Because of the following line of code, your function will always return “chicago”, because in the object lookup, you assigned the value “chicago” to the property named “charlie”. You need to make use of the val argument inside the brackets. Also, you have a typo for the correct value of the property “charlie”. It should be “Chicago” instead of “chicago”.