I'm trying to know how to calculate what is the real impact of changes like the following:
if ((payload.transactions?.length > 0) &&
(user.Type === UserType.Premium && user.status === UserStatus.Active)
) {
doSomeStuf();
}
const hasTransactions = () => payload.transactions?.length > 0;
const isActivePremium = () => {
return user.Type === UserType.Premium && user.status === UserStatus.Active;
}
if (hasTransactions() && isActivePremium()) {
doSomeStuf()
}
where conditions are moved from an if statement to a function in order to improve the code readability