As far as I can tell, you would have to have three if statements to replace:
Code:
//points should equal the sum of the match
anyway, so may as well do without:
Code:
else if (result1 == result2 || result1 == result3 || result2 == result3)
and have a total of four, instead of a total of five as would be required doing it the way you are trying.
This might work, but using if/if else statements seems clearer, and could more easily be expanded to include more results:
Code:
if (result1 == result2 & result2 == result3){
points = result1 * 3;
} else {
var results = [result1, result2, result3];
for(var i = 0; i < results.length; ++i){
for (var j = results.length - 1; j > -1; --j){
if(i !== j && results[i] == results[j]){
points = 2 * results[i];
}
}
}
}
Bookmarks