Using the chess.js library (see this link), I can know if a chess game is finished, by using game_over() function.
But how do I know who won and who lost?
in_checkmate()
Returns true or false if the side to move has been checkmated.
Combined with turn()
, it gives you the winner / loser (if it's not a draw).