I currently have a large switch statement:
switch (arg) {
case '+':
equals = num1 + num2;
break;
case '-':
equals = num1 - num2;
break;
case '*':
equals = num1 * num2;
break;
case '/':
equals = num1 / num2;
break;
case '%':
equals = num1 % num2;
break;
default:
error();
return;
}
I wanted to know if there was anyway that I could do something like
equals = num1 /** Do the operation defined by a variable */ num2
Or something like that so I dont have the large switch statement I wasn't even sure where to start looking for something like this since things like "Dynamic operators in js" doesnt bring up what im looking for, any help is apreciated.