honigle/src/lib/words.ts

25 lines
639 B
TypeScript

import { WORDS } from "../constants/wordlist";
import { VALIDGUESSES } from "../constants/validGuesses";
export const isWordInWordList = (word: string) => {
return (
WORDS.includes(word.toLowerCase()) ||
VALIDGUESSES.includes(word.toLowerCase())
);
};
export const isWinningWord = (word: string) => {
return solution === word;
};
export const getWordOfDay = () => {
// January 1, 2022 Game Epoch
const epochMs = 1641013200000;
const now = Date.now();
const msInDay = 86400000;
const index = Math.floor((now - epochMs) / msInDay);
return WORDS[index].toUpperCase();
};
export const solution = getWordOfDay();