Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 923 Bytes

chess.ts.chess.getcomment.md

File metadata and controls

43 lines (27 loc) · 923 Bytes

Home > chess.ts > Chess > getComment

Chess.getComment() method

Retrieve the comment if it exists.

Signature:

getComment(key?: string | number[]): string | undefined;

Parameters

Parameter Type Description
key string | number[] (Optional) FEN string or node indices, defaults to the current position

Returns:

string | undefined

Example

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"*