MCPcopy Index your code
hub / github.com/betomoedano/JavaScript-Coding-Interview-Questions / chess

Function chess

matrix/chess-board.js:1–14  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

1function chess(size) {
2 const board = new Array(size).fill(0).map((_) => new Array(size));
3
4 for (let row = 0; row < board.length; row++) {
5 for (let col = 0; col < board.length; col++) {
6 if ((row + col) % 2 === 0) {
7 board[row][col] = "♖";
8 } else {
9 board[row][col] = "♜";
10 }
11 }
12 }
13 console.log(board);
14}
15
16console.log(chess(2));
17console.log(chess(3));

Callers 1

chess-board.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected