Below is a chunk of some switch code used to create an array of objects which should be visible. Previously I combined case -1 and case 0 to reduce redundancy, but I am wondering if this code can be reduced in size and/or improved in readability.
var visibles = [];
switch (hrdid) {
case -1:
case 0:
if (row("tcd")) {
visibles = ['lc', 'ts2', 'rtc', 'ctb'];
if (row("cbr")) visibles.push('ccb2');
} else {
visibles = ['lc1', 'tc', 'rc', 'ico', 'ccb'];
}
if (hrdid == 0) visibles.push('bcf');
if (hrdid == -1) {
visibles.push('bcfa');
visibles.push('cpma');
}
break;
//case 1, etc...
}
//case 1
comment. – nickles80 Feb 15 '13 at 1:46{'-1':['lc', 'ts2', 'rtc', 'ctb', 'bcfa', 'cpma'], ...}
Then you can get the result you wantvisibles=visiblesByHrdid[String(hrdid)]
wherevisiblesByHrdid
holds the data. – abuzittin gillifirca Feb 15 '13 at 8:12