How can I check which of several booleans is true?
const isHappy = true
const isGrumpy = false
const isSad = false
switch(true) {
case isHappy: {
console.log('isHappy');
break;
}
case isGrumpy: {
console.log('isGrumpy');
break;
}
case isSad: {
console.log('isSad');
break;
}
default: {
console.log('Unknown');
break;
}
}
PreviousHow can I avoid using multiple if..else if...else if style code?NextHow can I subscribe to a series of numbers?
Last updated
Was this helpful?