Object Lookup: Don't understand why this doesn't work

Tell us what’s happening:
I have been looking at the answers, and still can’t understand why this object lookup code doesn’t work.

I thought that Modern JS practice would be to declare the lookup variable using const instead of var, but notice that this exercise still uses var.

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",
"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_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15.

Challenge: Using Objects for Lookups

Link to the challenge:

most of the JavaScript challenges are a few years old, so ES5 syntax is more used even when outdated, the new version of the curriculum that will be released in the near future will have ES6 as normal syntax instead of a specific topic

meanwhile, your issue is not that, it’s about what your function is returning

what’s being returned?

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