I have two practically identical functions. The only difference between them are one has +
and one has -
. These are used about 20 times in each function, so I'd love to make this simpler with a var.
I'm still very new to JavaScript, so I don't know where to start, but something like:
if ( blah blah ){
var symbol = '-';
} else{
var symbol = '+';
}
var example = value1 [symbol] value2;
Thanks