Hello, my name is Miheer Tamkhane, beginner in javascript and learning
freeCodeCamp javascript & I completed fcc given exercises and thought I've to share with you all.
Q-1.Convert the switch statement into an object called lookup. Use it to look up val and assign the associated string to the result variable.
Ans.
function phoneticLookup(val) {
var result = "";
var lookup = {
alpha: "Adams",
bravo: "Boston",
charlie: "Chicago",
delta: "Denver",
echo: "Easy",
foxtrot: "Frank",
};
result = lookup[val];
return result;
}
phoneticLookup("charlie");
Top comments (0)