Question on Challange "Using Objects for Lookups"

Question on Challange "Using Objects for Lookups"
0

#1

I get the error: “phoneticLookup(”") should equal undefined"
How can I add this “functionality” to react with undefind on empy val?

golfo

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

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

#2

Properties in objects are separated by commas(,), not semicolons (;).


#3

Thanks.
Changed that but ended up with the same result

results:
phoneticLookup(“alpha”) should equal "Adams"
phoneticLookup(“bravo”) should equal "Boston"
phoneticLookup(“charlie”) should equal "Chicago"
phoneticLookup(“delta”) should equal "Denver"
phoneticLookup(“echo”) should equal “Easy"
phoneticLookup(“foxtrot”) should equal “Frank"
phoneticLookup(””) should equal undefined
You should not use case, switch, or if statements

all ok until the last two


#4

I got it

I forgot = between lookup and {
and ; at the end of the object

working now with: (but interesting, that it worked with semicolon nearly to the end)


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

  // Only change code below this line

  
  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");