Skip to content

Instantly share code, notes, and snippets.

@DenisIzmaylov
Last active December 16, 2019 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DenisIzmaylov/270228be6908e4e7dc2a2baa33d46d32 to your computer and use it in GitHub Desktop.
Save DenisIzmaylov/270228be6908e4e7dc2a2baa33d46d32 to your computer and use it in GitHub Desktop.
Clean Code?
// Bad
books.forEach(book => {
if (book[title]) {
if (book[author]) {
console.log(book)
}
}
})
// Good
books.forEach(book => {
if (!book[title]) return
if (!book[author]) return
console.log(book)
}
// Bad
const hoursByDates = {}
hoursByDates['2019-12-01'] = 4
// Good
const hoursByDate = {}
hoursByDate['2019-12-01'] = 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment