Complex boolean expressions in if statements hide intent.
// dirty — what does this check?
function solve(user) {
if (user.age >= 18 && user.isActive && !user.isBanned && user.emailVerified) {
return 'eligible';
}
return 'not-eligible';
}Refactor by extracting the condition into a named predicate isEligible(user).solve(user, 'isEligible') → true/false · solve(user, 'getStatus') → 'eligible'/'not-eligible'
Sample tests