board[randomRowIndex][randomColumnIndex] = ‘B’;
^
TypeError: Cannot set property ‘1’ of undefined
if you want the code i can put it on my git
I don’t understand what I’m doing wrong I changed the arrays to var and honestly I’m about to give up
board[randomRowIndex][randomColumnIndex] = ‘B’;
^
TypeError: Cannot set property ‘1’ of undefined
if you want the code i can put it on my git
I don’t understand what I’m doing wrong I changed the arrays to var and honestly I’m about to give up
so then the first step would be to check why you get an index error:
console.log(board, numberOfRows, numberOfColumns);
board[randomRowIndex][randomColumnIndex] = 'B';
which shows me the board doesn’t seem properly generated, so lets inspect generatePlayerBoard
function:
console.log(board);
return board;
which seem to suggest that only one row has been created. So i looked at the for loop which should generate a number of rows, and saw the mistake.
you used “row” for both the row counter and assigning cell value. you must change one of them. I edit it in the github, you can checkit.