How to avoid lots of if-else in javascript (nodejs) <p>Based on a parameter, function should select a json file out of more 100 json and fire a query to other system.</p> <p>There will lots of query around in hundreds.</p> <p>Obviously if else and switch won't be manageable. I took a look for strategy patten in the javascript.</p> <pre><code>var queryCode = req.param('queryCode'); if(queryCode == 'x'){ //do something } else if( queryCode == 'y'){ //do something } else if( queryCode == 'z') { //do something } </code></pre> <p><code>// do something</code> might become large sometimes...<br> so I want to replace it something like strategy pattern. Which will be the best design. Thanks in advance for any suggestion for this problem.</p>