()
| 21 | |
| 22 | let unusedWikipediaFacts: string[] = []; |
| 23 | export const getRandomWikipediaFact = (): string => { |
| 24 | if (unusedWikipediaFacts.length === 0) { |
| 25 | unusedWikipediaFacts = clone(wikipediaFacts); |
| 26 | } |
| 27 | |
| 28 | const indexToRemove = Math.floor(Math.random() * unusedWikipediaFacts.length); |
| 29 | return unusedWikipediaFacts.splice(indexToRemove, 1)[0]; |
| 30 | }; |
| 31 | |
| 32 | export const getNumberWithCommas = (val: number): string => { |
| 33 | return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); |