Deeply nested if-statements

Consider the following examples of JavaScript code:

function if1(a) { if (a == 1) { return 100 } else { if (a > 1) { if (a > 3) { if (a < 5) { return 400; } else { return 1000; } } else { if (a == 3) { return 300; } else { return 200; } } } else { return 'any'; } } } function if2(a) { return a == 1 ? 100 : ((a > 1) ? ((a > 3) ? ((a < 5) ? 400 : 1000) : (a == 3 ? 300 : 200)) : 'any'); } function t(what) {console.log(what);} for(var i = 0; i < 9; i++) { t(if1(i) == if2(i)); // gives true 9 times }

Note: Deeply nested if-statements are a bad code smell. They result either in bloated functions (case 1) or compact ones, which are very hard to read and understand (case 2). Having to track an exponential number of paths is connected with increased likelihood for bugs. Use such constructs on your own risk.