create an object lookup javascript code example
Example 1: basic javascript using objects for lookups
var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
24:"C",
25:"B",
26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"
var value = 2;
alpha[value]; // "Y"
Example 2: using objects for lookups in javascript
var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
24:"C",
25:"B",
26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"
var value = 2;
alpha[value]; // "Y"