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) + } } } +}