I was wondering on how I can refactor that? I'm repeating myself I feel this is not the best way to write it :
if (operator === "+") {
strength += 2;
up = 4 * strength;
if (up > 40) up = 40;
final.base += up;
} else if (operator === "-") {
up = 4 * strength;
if (up > 40) up = 40;
final.base -= up;
strength -= 2;
}
I don't really see a way to properly refactor that since position is important. Is there a way to clean this function?