This probably has been asked before but all I can find are questions regarding C and Bash etc.
Basically I'm having a really hard time getting my head around function parameters and what they reference.
I know that you usually set paramters when you call the function e.g. doSomething(3,'Hello')
etc, but when I read code from tutorials like so;
window.onload = initAll;
function initAll() {
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,0,0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4);
var colBasis = colPlace[thisSquare] * 15;
var newNum = colBasis + getNewNum() + 1;
document.getElementById(currSquare).innerHTML = newNum;
}
function getNewNum() {
return Math.floor(Math.random() * 15);
}
Where is setSquare()
getting the parameter of thisSquare
from?