Hello all,
I am stuck here and I have no idea what’s wrong. Can sbdy help me out and explain why this doesn’t work please? Thank you !
// Setup
function phoneticLookup(val) {
let result = "";
// Only change code below this line
let lookup {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};
// Only change code above this line
return result;
}
phoneticLookup("charlie");
In the future, if you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.
use switch statement
switch(val){
case "alpha":
result="Adams"
break;
case "bravo" :
result = "Boston"
break;
case "charlie":
result ="Chicago"
break;
....
.....
....
default:
result="Not Found"
}
Thank you for your answer. Actually, what is asked remove a switch
" Convert the switch statement into an object called lookup . Use it to look up val and assign the associated string to the result variable."
This is the solution that is given when you click on “get a hint”
function phoneticLookup(val) {
var result = "";
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank"
};
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
I did click on “Ask for help” but I think that since I had to create the account, it didn’t redirect me there or I clicked somewhere I wasn’t supposed to ? Sorry