JSFiddle - React, Tailwind, and code Playground

JavaScript

const altChainedTernary = (x, y, z) => x ? 1 : y ? 2 : z ? 3 : 4
// Inside this function the ternary conditions are always nested as alternate (right-hand) values

const conChainedTernary = (x, y, z) => x ? y ? z ? 1 : 2 : 3 : 4
// Inside this function the ternary conditions are always nested as consequent (left-hand) values

const log = result => console.log(result)

altChainedTernary(0, 0, 1) // -> 3
// The parameter order here requires two falsy values for the third value to be returned
conChainedTernary(0, 0, 1) // -> 4
// The second and third values are here entirely unecessary. The same can be achieved with
conChainedTernary() // -> 4
// In the consequential version the first condition has the most priority. For related clauses and some data structures
// this often makes more sense. Here's a less abstract example:

const getFeeCon = user => user.isMember ? user.isFounder ? 2.50 : 3.50 : 4.50
// all test conditions are located on the left and all possible return values on the right. The condition that matters most is the one we
// check first, i.e. if the user is a member

const getFeeAlt = user => user.isFounder ? 2.50 : user.isMember ? 3.50 :  4.50
// we here split the test conditions and values and need to reverse the order of the conditions being checked to achieve a similar result.
// we also emphasise the wrong condition - if a faulty or hacked user manages to set this property, we skip checking the membership value

let guest = { isMember: false, isFounder: false }
let member = { isMember: true, isFounder: false }
let founder = { isMember: true, isFounder: true }
let faultyUser = { isMember: false, isFounder: true } // assumes all founders should be members (dogfooding people!)

log('g: ' + getFeeCon(guest))
log('m: ' + getFeeCon(member))
log('fo: ' + getFeeCon(founder))
log('fa: ' + getFeeCon(faultyUser)) // faultyUser gets default fee of 4.50

log('g: ' + getFeeAlt(guest))
log('m: ' + getFeeAlt(member))
log('fo: ' + getFeeAlt(founder))
log('fa: ' +...