LLD - Design — Chess Game
Given this code snippet for a board and pieces, what will be the output of
console.log(board.pieces[0].type);?
class Piece {
constructor(type, position) {
this.type = type;
this.position = position;
}
}
class Board {
constructor() {
this.pieces = [];
}
addPiece(piece) {
this.pieces.push(piece);
}
}
const board = new Board();
board.addPiece(new Piece('Knight', 'B1'));
