Tell us what’s happening:
I was sick of spending 30 minutes on this, so I went to get a hint. Nothing different between my code and its. But I decided maybe there was a comma or something I didnt see. I deleted my code and copy/pasted the hint code, note the solution. Didnt work? I don’t know whats wrong with the code.
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("charlie");
It’s weird sometimes how they write the return values. You can either change the return value (tests will pass just fine as long as it is returning what it should) or you can update what the variable result should contain prior to the return. Hope that makes sense?
// 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"
};
//add the following line:
result = //put required value here to make the tests pass
// Only change code above this line
return result;
}
// Change this value to test
phoneticLookup("charlie");
Only problem with that is, I need to make the var work as a if statement without using the if statement. I need to give it Adams when it states phoneticLookup(“alpha”) and so on. And I can’t “cheat it” by using switch or if. I used the code in the hint. Just returning all of it doesnt work either