HTML JS

HOW TO CREATE A GRID IN JAVASCRIPT

1) HTML & CSS

<div id="grid"></div>   <style> #grid {  display: grid;  grid-template-columns: auto auto auto; } </style>

2) JAVASCRIPT

// DATA ARRAY var data = [   ["A", "B", "C"], ["D", "E", "F"] ];   // LOOP + ADD CELLS let container = document.   getElementById("grid"); for (let i of data) { for (let j of i) {   let cell = document.     createElement("div");   cell.innerHTML = j;   cell.className = "cell";   container.appendChild(cell); }}