Closed ivan-unfolds closed 1 year ago
You could refactor the following
https://github.com/fac26/week2-database-nkndi/blob/6ee7693fc6b0f30adca74545df0dde8c19a160f5/routes/addBook.js#L32-L40
To something like
const author_id = getAuthorId(author)?.id || inserteAuthorToDB({ name: author }).id;
Though it's a matter of subjective opinion whether this is better so feel free to ignore. You could argue that your solution is more readable.
I agree, using nullish coalescing operator is not only more terse, but also easier to understand than 8 separate lines of code.
Following your advise, done Thank you, Ivan
You could refactor the following
https://github.com/fac26/week2-database-nkndi/blob/6ee7693fc6b0f30adca74545df0dde8c19a160f5/routes/addBook.js#L32-L40
To something like
const author_id = getAuthorId(author)?.id || inserteAuthorToDB({ name: author }).id;
Though it's a matter of subjective opinion whether this is better so feel free to ignore. You could argue that your solution is more readable.