0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ビンゴシートを作成

Last updated at Posted at 2021-01-13

マスは二次元配列で作成(過去のオセロゲームを参考)
真ん中はfree
ページ更新するたびに中身を更新
bの列には1~15
iの列には16~31
nの列には31~45
gの列には46~60
oの列には61~75
を入れるようにする


const sheet =document.getElementById("field")

function newSheet() {
    for (var x = 0; x < 6; x++){
        const tr = document.createElement("tr")
        sheet.appendChild(tr)

        for (var y = 0; y < 5; y++){
            var td = document.createElement("td");
            if (x === 0) {
                switch (y){
                case 0:
                    td.textContent ="B"
                    break;
                case 1:
                    td.textContent = "I"
                    break;
                case 2:
                    td.textContent = "N"
                    break;
                case 3:
                    td.textContent = "G"
                    break;
                case 4:
                    td.textContent = "O"
                    break;
                }
            } else {
                switch (y){
                    case 0:
                        td.textContent = (Math.floor(Math.random() * 15 + 1))
                        break;
                    case 1:
                        td.textContent = (Math.floor(Math.random() * 15 + 16))
                        break;
                    case 2:
                        td.textContent = (Math.floor(Math.random() * 15 + 31))
                        if (x === 3) {
                            td.textContent = "free"
                        }
                        break;
                    case 3:
                        td.textContent = (Math.floor(Math.random() * 15 + 46))
                        break;
                    case 4:
                        td.textContent = (Math.floor(Math.random() * 15 + 61))
                        break;
                    }
            }
               tr.appendChild(td)
        }
    }
    
}

newSheet()
0
0
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?