Home > chess.ts > Chess > getComment
Retrieve the comment if it exists.
Signature:
getComment(key?: string | number[]): string | undefined;
Parameter | Type | Description |
---|---|---|
key | string | number[] | (Optional) FEN string or node indices, defaults to the current position |
Returns:
string | undefined
const chess = new Chess()
chess.loadPgn("1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 {giuoco piano} *")
chess.getComment(
'r1bqk1nr/pppp1ppp/2n5/2b1p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4'
)
// -> "giuoco piano"
chess.getComment(
[0,0,0,0,0,0]
)
// -> "giuoco piano"*