triviafunction
The trivia about one country, by its alpha-2 code in either case.
Import it
import { trivia } from "@johnmorrisdotca/kuni/trivia";
Definition
function trivia(code: string): CountryTrivia | null
Parameters
| Name | Type | Description |
|---|---|---|
code | string | An ISO 3166-1 alpha-2 code, "JP" or "jp"; for an alpha-3 or numeric code, pass |
Returns
CountryTrivia | null
The country's trivia, frozen; null for anything that is not one of the 250 codes.
Examples
import { trivia } from "@johnmorrisdotca/kuni/trivia";
console.log(trivia("CA")?.officialLanguages); // ["en", "fr"]
console.log(trivia("AU")?.largestCity?.name.en); // "Sydney"
console.log(trivia("IN")?.inception); // { "year": 1947, "day": "1947-08-15" }
console.log(trivia("XX")); // null[ 'en', 'fr' ]
Sydney
{ year: 1947, day: '1947-08-15' }
nullWhat it prints (run when this page was built)