JSFiddle - React, Tailwind, and code Playground

by beebeekei

HTML

<div id='box'></div>

CSS

div {
   width: 20px;
   height: 20px;
}

.class1 {
   background: red;
}

.class2 {
background: green;
}

.class3 {
background: orange;
}

JavaScript

var list = ['class1', 'class2', 'class3'];
document.getElementById('box').className = list[ Math.floor( Math.random() * list.length ) ];