Skip to content

Ignore earlier guessed words #139

@stelian56

Description

@stelian56

It is proposed that guessed words be stored in the app's local storage and not used as challenges anymore. Code changes to Game.tsx:

var usedWords = JSON.parse(localStorage.getItem('usedWords') || '[]');

function randomTarget(wordLength: number): string {
  const eligible = targets.filter((word) => word.length === wordLength
    && !(usedWords.includes(word)));
  . . .

  const onKey = (key: string) => {
  . . .
    const saveUsedWord = (word: string) => {
        usedWords.push(target);
        localStorage.setItem('usedWords', JSON.stringify(usedWords));
    };
      
    if (currentGuess === target) {
      setHint(gameOver("won"));
      setGameState(GameState.Won);
      saveUsedWord(target);
    }
    . . .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions