I have a function that's supposed to render random colors, but without repeating the colors.
Meaning if blue is randomly selected, it can't be selected again. Of course this means there needs to be a default value. I was thinking of using a switch
statement.
Here is my current code:
const colors = {
grey: '#BDC8D1',
blue: '#0500FF',
pink: '#FF00C7',
orange: '#FF7A00'
}
const randomColor = () => {
let keys = Object.keys(colors)
return colors[keys[keys.length * Math.random() << 0]]
}