The if...else statement is used to make decisions based on the truthiness of a boolean expression, and the if block
executes when the expression is truthy, while the else block executes when the expression is falsy.
Wrapping a boolean expression in an if...else statement and returning true or false in the respective blocks
is redundant and unnecessary. It can also make the code harder to maintain, as it adds unnecessary lines of code that need to be read and
understood.
if (expression) {
return true;
} else {
return false;
}
Simplify the code and return the boolean expression (or its negation) directly to make the code more concise and easier to read and maintain.
return expression;
If the caller expects a boolean and the result of the expression is not a boolean, use double negation for proper conversion.
return !!expression;