here is the code for making a 2d array to be used as a board for conways game of life in node.js. i am having a problem with displaying the board. the output looks like this.
['-','-','-']
['-','-','-']
['-','-','-']
however i want it to look like this
---
---
---
this is the code right now. Does anyone have any suggestions?
var createBoard = (width, height) => {
board = [];
row = [];
for (var i = 0; i < width; i++) {
for (var j = 0; j < height; j++) {
row.push("-");
}
board.push(row);
row =[];
}
return (board);
}
var displayBoard = (board) =>{
for (var i = 0; i < board.length; i++) {
console.log(board[i]);
}
}
gameBoard = createBoard(3,3);
displayBoard(gameBoard);