Hello Digital Point, I was reading my JavaScript book the other day... it shows an 'Bingo Card' question/example but the book does not really explain the logic behind question/example. I typed it in several times today trying to grasp the logic... but I do not get the logic so I need an explanation of how it works... window.onload = newCard; function newCard() { if (document.getElementById) { for (var i=0; i<24; i++) { setSquare(i); } } else { alert("Sorry, your browser doesn't support this script"); } } function setSquare(thisSquare) { var currSquare = "square" + thisSquare; var colPlace = new Array(0,1,2,3,4,0,1,2,3,4,0,1,3,4,0,1,2,3,4,0,1,2,3,4); var newNum = (colPlace[thisSquare] * 15) + Math.floor(Math.random() * 15) + 1; document.getElementById(currSquare).innerHTML = newNum; } Code (markup): I understand the functions, methods, and parameters work... but this is the line of code that causing my confusion. var newNum = (colPlace[thisSquare] * 15) + Math.floor(Math.random() * 15) + 1; Code (markup):
The script is filling in the bingo card by rows and columns. The line of code you ask about generates a random number based on 15 times the column plus a random number between 1 and 15. The purpose is to create a bingo card with numbers that fall within a specific range in each column.