From e09e184ee21973ee369b880e8bb2feb4bdf429b1 Mon Sep 17 00:00:00 2001 From: Richard Halsall <–richard-glyn.halsall@informatik.hs-fulda.e> Date: Fri, 27 Jan 2023 13:23:13 +0100 Subject: [PATCH] =?UTF-8?q?Zellenbeschriftung=20zur=20Tabelle=20Generator?= =?UTF-8?q?=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- schlangen_und_leitern/js/makeBoard.js | 31 +++++++++++++++++++-------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/schlangen_und_leitern/js/makeBoard.js b/schlangen_und_leitern/js/makeBoard.js index a1af2de..799392f 100644 --- a/schlangen_und_leitern/js/makeBoard.js +++ b/schlangen_und_leitern/js/makeBoard.js @@ -1,23 +1,36 @@ function drawBoard(){ + + let count = 100; let tbl = document.getElementById("board"); - + for (let y = 0; y < 10; y++){ + let myRow = document.createElement("tr"); - myRow.id = "row" + y; - - + myRow.id = "row" + (9 -y); tbl.appendChild(myRow); - let row = document.getElementById("row" + y); - - + let row = document.getElementById("row" + (9 -y)); + + if(y == 0 || (y % 2 == 0) ){ for(let x = 0; x < 10; x++){ - + count--; let cell = document.createElement("td"); + cell.id = "cell" + x row.appendChild(cell); - } + cell.innerHTML = (count) + } + } + else { + for(let x = 0, z = 9; x < 10; x++, z--){ + count--; + let cell = document.createElement("td"); + cell.id = "cell" + x + row.appendChild(cell); + cell.innerHTML = ((count - z) + x) + } } } +}