better?
if (
(checkout.includedProducts || checkout.excludedProducts) &&
(checkout.includedProducts.length > 0 || checkout.excludedProducts.length > 0)
)
I need at least one of those to exist and ensure it has at lease 1 item on array
checkout.includedProducts?.length could be helpful https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
can't you assume that checkout.includedProducts is set?
nope, it's not mandatory it will be returned from the api
this is good then. If you have access to ES2020
bruh, add a method to checkout object which makes all those checks. It's breaking LoD
https://en.wikipedia.org/wiki/Law_of_Demeter
Обсуждают сегодня