javascript - How to make a maintainable list of conditions -


i have code, in time hard read , maintain - numbers come , go. how make easy accessible maintainable list of conditions? should use array or else?

var cs = 123456; //some integer  if (cs >= 320000      && cs <= 320026      || cs == 320141      || cs == 320143      || cs == 320145      || cs == 320147      || cs == 320149      || cs == 320151) {      new = 'y';  } else if (cs >= 320100      && cs <= 320112      || cs >= 320114      && cs <= 320116      || cs >= 320123      && cs <= 320128      || cs == 320142      || cs == 320144      || cs == 320146      || cs == 320148      || cs == 320150      || cs == 320152) {      new = 'n';  } else {      new = 'unknown'; }; 

yes, need array , indexof method.

example:

if (cs >= 320000 && cs <= 320026  || $.inarray(value, valuesarray) > -1) {  -- } 

https://stackoverflow.com/questions/16910305/if-or-shorter-way/16910313#16910313


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -