Another possibility, if your end goal is to simply randomly select between a number of equally-weighted values is to write a simple function that accepts those values, and either returns one or returns a function, which when called returns one. Here's the second version:
const randomChoice = (vals) => () => vals[Math.floor(vals.length * Math.random())]
const randomColor = randomChoice(['red', 'blue', 'yellow'])
document.body.style.backgroundColor = randomColor()
Here randomChoice
is a utility function that might be stored elsewhere, and randomColor
generates one of the items you need.
This might not meet your needs. But if the three branches were just placeholders, and you would eventually need the nine the code suggests, then this might be the easiest to keep up-to-date.
This could be expanded to handle unequal weightings, but it would be more complex. There are plenty of places where this sort of random choice could be useful.