This seems like a pretty basic question, but I can't understand why this is happing. I am new to JavaScript.
When I have do something like this...
<!-- variable defined but not used -->
var theLeftSide = document.getElementById("leftSide");
function generateFaces(){
<!-- some code here -->
document.getElementById("leftSide").appendChild(face);
}
I have no problem, and the code runs. But when I instead use the variable I have declared, it no longer works because "theLeftSide is null".
This doesn't work...
<!-- variable declared but not used -->
var theLeftSide = document.getElementById("leftSide");
function generateFaces(){
<!-- some code here -->
theLeftSide.appendChild(face);
}
Why is this happening? I think I put all the relevant code, but I can add to it if need be.