Just add parentheses.
var somevar = (b1 ? (b2 ? b3 : b4) : (b5 ? b6 : (b7 ? b8 : (b9 ? b10 : b11))))
those.
if (b1) {
if (b2) {
b3
} else {
b4
}
} else {
if (b5) {
b6
} else {
if (b7) {
b8
} else {
if (b9) {
b10
} else {
b11
}
}
}
}
Or make it shorter.
if (b1) {
if (b2) {
b3
} else {
b4
}
} else if (b5) {
b6
} else if (b7) {
b8
} else if (b9) {
b10
} else {
b11
}
Start at the far right. whenever you find a ? b : cadd parentheses to it.
For example:
a ? b ? c : d : e
a ? (b ? c : d) : e
(a ? (b ? c : d) : e)
source
share