Reference · Marking, scores and game rules
typeWordGamefunction
One key typed, now being the time in milliseconds (the first key starts the clock). A key the round does not take, or a round that is over, changes nothing.
Import it
import { typeWordGame } from "@johnmorrisdotca/kotoba";
Definition
function typeWordGame(game: WordGame, key: string, now?: number): WordGame
Parameters
| Name | Type | Description |
|---|---|---|
game | WordGame | The current immutable word-game state. |
key | string | One accepted keyboard character. |
now (optional) | number | Host clock time in milliseconds. |
Returns
WordGame
One key typed, now being the time in milliseconds (the first key starts the clock). A key the round does not take, or a round that is over, changes nothing.
Examples
import { startWordGame, typeWordGame } from "@johnmorrisdotca/kotoba";
const game = startWordGame("en",5,"apple");
const typed = [..."apple"].reduce((state,key)=>typeWordGame(state,key,1000),game);
console.log(typeWordGame(game,"a",1000).typed);[ 'a' ]What it prints (run when this page was built)