basic javascript using objects for lookups

Solutions on MaxInterview for basic javascript using objects for lookups by the best coders in the world

showing results for - "basic javascript using objects for lookups"
Fabrizia
19 Mar 2020
1function phoneticLookup(val) {
2  var result = "";
3
4  var lookup = {
5     "alpha":"Adams",
6     "bravo":"Boston",
7     "charlie":"Chicago",
8     "delta":"Denver",
9     "echo":"Easy",
10     "foxtrot":"Frank",
11  };
12  result = lookup[val];
13  return result;
14}
15
16phoneticLookup("charlie");
17console.log(phoneticLookup("alpha")); // to test
18console.log(phoneticLookup("")); //to test
19
Luna
03 Jul 2018
1var alpha = {
2  1:"Z",
3  2:"Y",
4  3:"X",
5  4:"W",
6  24:"C",
7  25:"B",
8  26:"A"
9};
10alpha[2]; // "Y"
11alpha[24]; // "C"
12
13var value = 2;
14alpha[value]; // "Y"
15
Juan Sebastián
17 Apr 2017
1var alpha = {
2  1:"Z",
3  2:"Y",
4  3:"X",
5  4:"W",
6  24:"C",
7  25:"B",
8  26:"A"
9};
10alpha[2]; // "Y"
11alpha[24]; // "C"
12
13var value = 2;
14alpha[value]; // "Y"
similar questions
queries leading to this page
basic javascript using objects for lookups