DEV Community

loading...

freeCodeCamp js solved questions

miheertamkhane profile image MiheerTamkhane ・1 min read

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");
Enter fullscreen mode Exit fullscreen mode

Thank you, Hope it will help you.

Discussion (0)

pic
Editor guide