Using Objects for Lookup is giving me some stress

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", 
    "foxtrot" : "Frank",
};
  // Only change code above this line
  return result;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36.

You have

var result = "";
return result;

result is not changed so your returned value is an empty string
And you are not doing anything with the parameter of the function, val

Can you manage it with these hints?

If not, please ask again

Hi, thanks for your help. If I include
return lookup [val]; it tells me not to change the return value. and doesn’t run my code that’s why I’m stumped.

So add an other line where you change result, above the line that says "// Only change code above this line

Thanks a bunch, that worked. You’re amazing.

What you did, with return lookup[val] is not wrong if you were coding outside of test limits, but in this environment you need to respect certain things, or the tests wouldn’t work, like in this case change things only where allowed, even if that would mean having variables that in other situations wouldn’t be necessary, or restrictions to what you could do

Okay, I understand now. Thanks a lot