Just come across a stupid piece of JS program today in some web site:
function preselectSS(what)
{
if (what == 1) document.getElementById("selSS").selectedIndex = 0;
else if (what == 2) document.getElementById("selSS").selectedIndex = 1;
else if (what == 3) document.getElementById("selSS").selectedIndex = 2;
else document.getElementById("selSS").selectedIndex = 3;
}
Isn’t it a lot nicer to write it as
function preselectSS(what) {
document.getElementById("selSS").selectedIndex = (what > 0 && what <= 3) ? (what - 1) : 3;
}
The world is full of stupid programmers writing stupid programs.





