JSFiddle - React, Tailwind, and code Playground

by Steven Tang

HTML

<table>
<td>
<div id="1"></div>
</td>
<td>
<div id="2"></div>
</td>
<td>
<div id="3"></div>
</td>
<td>
<div id="4"></div>
</td>
<table>

CSS

div {
  background-color: white;
  height: 150px;
  width: 100px;
  display: block;
};

.blackTile {
  background-color: black;
  height: 150px;
  width: 100px;
  display: block;
}

JavaScript

var updateBlackTile = function() {
var blackTile = Math.floor(math.round(math.random*4);

switch(blackTile):
	case 1:
		document.getElementByID('1').className = "blackTile";
		break;
	case 2:
		document.getElementByID('2').className = "blackTile";
		break;
	case 3:
		document.getElementByID('3').className = "blackTile";
		break;
	case 4:
		document.getElementByID('4').className = "blackTile";
		break;
 };
 updateBlackTile()