I need to set i depending on a condition:
let i = null
nightmode === true ? i = 1 : i = 0
Is it possible to declare i within the ternary expression, or does it have to be in outside of it (to handle scoping)?
You could use the ternary directly as assignment for the value.
let i = nightmode === true ? 1 : 0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With