Home > chess.ts > Chess > getComments
Retrieve comments for all positions, keyed by FEN string.
Signature:
getComments(key?: 'fen' | 'indices'): CommentMap;
Parameter | Type | Description |
---|---|---|
key | 'fen' | 'indices' | (Optional) Key by 'fen' or node 'indices' |
Returns:
const chess = new Chess()
chess.loadPgn("1. e4 e5 {king's pawn opening} 2. Nf3 Nc6 3. Bc4 Bc5 {giuoco piano} *")
chess.getComments()
// -> {
// "rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq e6 0 2": "king's pawn opening",
// "r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3": "giuoco piano"
// }