DEV Community

loading...

Discussion on: S.O.L.I.D. Principles around You, in JavaScript

Collapse
jeckerson profile image
Jeckerson

This:

if(roles.includes(user.role)){
    return true; 
}else{
    return false;
}

Can be transformed to this:

if (roles.includes(user.role)) {
    return true; 
}

return false;

Or even to this:

return roles.includes(user.role);
Collapse
francescoxx profile image
Francesco Ciulla Author

Hello Jeckson,

of course it can be transformed like that, the idea here is to be as clear as possible! Feel free to use a more concise syntax