チェス用のダイアグラムを作成するJavaScriptスクリプトを書いてください。
let board = document.createElement('div');
board.style.width = '400px';
board.style.height = '400px';
document.body.appendChild(board);

let rows = 8;
let cols = 8;

// Create board checkerboard
for (let x=0;x<rows;x++) {
  let row = document.createElement('div');

  // Create checker pattern
  for (let y=0;y<cols;y++) {
    let cell = document.createElement('div');
    cell.style.width = (400/cols).toString() + 'px';
    cell.style.height = (400/rows).toString() + 'px';

    if (x % 2 === 0){
      if (y % 2 === 0) {
        cell.style.backgroundColor = "white";
      }
      else {
        cell.style.backgroundColor = "black";
      }
    }
    else {
      if (y % 2 === 0) {
        cell.style.backgroundColor = "black";
      }
      else {
        cell.style.backgroundColor = "white";
      }
    }

    row.appendChild(cell);
  }

  board.appendChild(row)
}