In the code below, even if the if/else statement evaluates to true or false, the doSomething() function is being called. What I was wondering is if there is a way to refactor this code to make it "DRYer." In my actual code, the body of the loop is longer than just a single function being called, so I figure it's worth refactoring.
if (somethingIsTrue) {
array1.forEach(val => {
doSomething(val);
});
} else {
array2.forEach(val => {
doSomething(val);
});
}