payload = {type: 3}
const type = payload.type || state.active === "period" ? 1 : 2;
// type returns 1
I'm surprised by the return of type
which is 1.. I was expecting it to be 3.. What happened here? What I want to really achieve is if the type index is not available then state.active === "period" ? 1 : 2
will be the basis of the value of type..
How to achieve this in a clean one line?