JSFiddle - React, Tailwind, and code Playground

by alexb

TypeScript

type Game = [number, number];
type Set = Game[];
type Match = Set[];
type Point = 0 | 1;

const leadingScore = (game: Game) => Math.max(...game);
const trailingScore = (game: Game) => Math.min(...game);
const isWon = (game: Game) =>
	leadingScore(game) > 3 && leadingScore(game) - trailingScore(game) > 1;
const winner = (game: Game) = isWon(game) ? Number(game[1] > game[0]) : undefined;

const addPoint = (game: Game) => {