I think you are too smart, which is not so:
var optionsSelected = 0; if( opt1 ) optionsSelected++; if( opt2 ) optionsSelected++; if( opt3 ) optionsSelected++; if( optionsSelected !== 1 ) { throw new Error("Exactly one option must be set"); }
Of course, I can play a smart game too:
if( opts.filter(Boolean).length !== 1 ) { throw new Error("Exactly one option must be set"); }
source share