Let use another code sample (like fizz buzz kata):
if ( x % 3 === 0 && x % 5 === 0) {
return "fizz buzz";
} else if ( x % 3 === 0 ) {
return "fizz";
} else if ( x % 5 === 0 ) {
return "buzz";
} else {
return x
}
Note: You can use the result as a expectation in tests, and try to write some new code with Test-Driven Development.
For instance, in OOP you can use polymorphism: refactoring.com/catalog/replaceConditionalWithPol…
Let us know if you found an elegant way to answer your needs.