-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Open
Labels
Description
In this part of best practice I found a part of code
// bad
inbox.filter((msg) => {
const { subject, author } = msg;
if (subject === 'Mockingbird') {
return author === 'Harper Lee';
} else {
return false;
}
});
// good
inbox.filter((msg) => {
const { subject, author } = msg;
if (subject === 'Mockingbird') {
return author === 'Harper Lee';
}
return false;
});
But, it seems that we can write this part of code better:
inbox.filter((msg) => {
const { subject, author } = msg;
return subject === 'Mockingbird' && author === 'Harper Lee';
});
Isn't it?
Thanks,
Andrii