JSFiddle - React, Tailwind, and code Playground

by Alexey Mishin

HTML

<body>
  
</body>

JavaScript

function getRandomColor() {
	let red = Math.round(Math.random() * 255),
			green = Math.round(Math.random() * 255),
			blue = Math.round(Math.random() * 255);

  return "#" + red + green + blue;
 	   
}

function makeTable(rows, cols) {
	var table = document.createElement('table');

	for (let i = 0; i < rows; i++) {
  	var row = document.createElement('tr');
    row.classList.add(`row-${i+1}`);
    
    for (let k = 0; k < cols; k++) {
    	var cell = document.createElement('td');
      cell.classList.add(`cell-${i+1}-${k+1}`);
      cell.style.backgroundColor = getRandomColor();
      cell.style.width = "20px";
      cell.style.height = "20px";
      row.appendChild(cell);
    }
    
   table.appendChild(row); 
  }
  
  document.body.appendChild(table);
}

makeTable(20, 20);