I'm calling this function from my html (and in some cases from another function in my JavaScript). These type of switch
statements are starting to litter my code. Is there a more elegant solution to these if
statements? I wish I could pass a reference to the variables I want to modify. I'm finally asking the question because now I have a situation where if I do it this same way, I'm going to have an ugly switch
statement with hundreds of cases which I'm guessing not only looks ugly, but will hurt performance.
function incCriteriaStats(exp){
switch (exp) {
case "a":
numOfA++;
break;
case "b":
numOfB++;
break;
case "c":
numOfC++;
break;
case "d":
numOfD++;
break;
case "e":
numOfE++;
break;
case "f":
numOfF++;
break;
case "g":
numOfG++;
break;
}
|