Open hadson19 opened 7 years ago
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
In this specific case, you're totally right - however, rather than applying that change, I'd rather alter the bad/good examples so that they show complex logic.
In this part of best practice I found a part of code
But, it seems that we can write this part of code better:
Isn't it?
Thanks, Andrii