I am very new to Javascript and am trying to translate a game i made in python into javascript. I am currently trying to get keyboard input for the game. Whenever i run this however it gives me the following error: Uncaught TypeError: Cannot read property '0' of undefined(at line 4 in this example)
Board is a 2d array used to store the board and i have tested that before the addEventListener statement Board is not undefined.
Why is this error happening and what should i do to fix it. As mentioned before i am a complete beginner at javascript so simple explanations would be greatly appreciated. Kind regards
document.addEventListener('keydown', function(event){
if(event.keyCode == 65){
console.log(Board)
Board[this.block1[0]][this.block1[1]]=null;
Board[this.block2[0]][this.block2[1]]=null;
Board[this.block3[0]][this.block3[1]]=null;
Board[this.block4[0]][this.block4[1]]=null;