Tell us what’s happening:
I have the answer, because I looked it up in the hints, which isn’t great I know, but why does this work? Wouldn’t the function just stop at return lookup[val]? Why is “return result” even there? I have no idea what I’m doing, I couldn’t even come up with an answer that didn’t work, all I could manage was writing the lookup object, and then I had absolutely no idea what I was doing.
Your code so far
// Setup
function phoneticLookup(val) {
var result = "";
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
}
return lookup[val];
return result;
}
console.log(phoneticLookup("alpha"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36.
Hi there i think i know what you where trying to do. this was mention by @nhcarrigan
but i will explained in detailed.
There were 2 ways of trying to get back the answer as return:
return lookup[val];
This just returning the object key value pair(“Adams”), witch will be the decent and the right way of doing it.
return result = lookup[val];
This is another way of doing it, but by creating an empty string var result = ""; as result meaning storing your value return, and return it. In this particular case you needed to create an extra variable an assigned as empty string.
I think they/you will trying to get the returning value in two different methods.
Hope this helps clarify a bit more.