javascript - Case statement appears to not check all combinations -


i having issue case statement not checking combinations of defined variables. tried troubleshoot issue process of elimination , discovered work individually not in group. question see errors or have suggestions otherwise tackle this?

switch (true) {     case pv131 != 'lab.cmc1' && pv134 == 'xyz' && obr21 == 'misc2':     case pv131 != 'lab.cmc2' && pv134 == 'xyz' && obr21 == 'misc2':     case pv131 != 'lab.cmc3' && pv134 == 'xyz' && obr21 == 'misc2':     case pv131 != 'lab.cmc4' && pv134 == 'xyz' && obr21 == 'misc2':     case pv131 != 'lab.cmc5' && pv134 == 'xyz' && obr21 == 'misc2':     msg['msh']['msh.8']['msh.8.1'] = '12345678';     break; } 

thank - matt

similar suggested, following working solution:

case ['lab.cmc'].indexof(pv131) === -1 && pv134 === 'xyz' && obr21 === 'misc2': msg['msh']['msh.8']['msh.8.1'] = '12345678'; break; 

i able reduce repetition having check 'lab.cmc'.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -