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
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
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"