// Room dimension in cm
const roomLength = 200;
const roomWidth = 300;
// Tile dimension in cm
const tileLength = 30;
const tileWidth = 30;
// Interstice width in cm
const intersticeWidth = 0;
// Calculate the number of rows and columns for the grid
const numRows = Math.ceil(roomLength / (tileLength + intersticeWidth));
const numCols = Math.ceil(roomWidth / (tileWidth + intersticeWidth));
// Create a new div element to hold the grid
const grid = document.createElement(„div”);
grid.style.display = „grid”;
grid.style.gridTemplateColumns = `repeat(${numCols}, ${tileWidth}cm)`;
grid.style.gridGap = `${intersticeWidth}cm`;
// Create tiles and add them to the grid
for (let i = 0; i < numRows; i++) {
for (let j = 0; j < numCols; j++) {
const tile = document.createElement("div");
tile.style.backgroundColor = "#CCC";
grid.appendChild(tile);
}
}
Tile Grid