Linked Questions

Popular Questions

Test multiple conditions in javascript switch statement

Asked by At

Is it possible to test multiple conditions in a javascript switch statement? For example:

switch (var1 && var2) {
    case var1 == 1 || var2 == 1:
        alert("1");
        break;
    case var1 == 2 || var2 == 2:
        alert("2");
        break;
        //etc...
}

The reason I am asking is because this would be a lot easier than using tons of if or switch statements.

Related Questions