Browse Source

Zellenbeschriftung zur Tabelle Generator hinzugefügt

main
Richard Halsall 2 years ago
parent
commit
e09e184ee2
  1. 27
      schlangen_und_leitern/js/makeBoard.js

27
schlangen_und_leitern/js/makeBoard.js

@ -1,23 +1,36 @@
function drawBoard(){ function drawBoard(){
let count = 100;
let tbl = document.getElementById("board"); let tbl = document.getElementById("board");
for (let y = 0; y < 10; y++){ for (let y = 0; y < 10; y++){
let myRow = document.createElement("tr");
myRow.id = "row" + y;
let myRow = document.createElement("tr");
myRow.id = "row" + (9 -y);
tbl.appendChild(myRow); 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++){ for(let x = 0; x < 10; x++){
count--;
let cell = document.createElement("td"); let cell = document.createElement("td");
cell.id = "cell" + x
row.appendChild(cell); 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)
}
} }
} }
}

Loading…
Cancel
Save