Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

feat(dictionary): Add a real dictionary with words #7

Open
wants to merge 1 commit into
base: feat_win_reset_Add_win_condition_and_res
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion wordle-tutorial/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import classnames from "classnames";
import { useEffect, useState } from "react";
import dictionary from "./dictionary.json"
import "./App.scss";

const LETTERS = "abcdefghijklmnopqrstuvwxyz";

function App() {
// The word the user is trying to guess
const [actualWord] = useState("magic");
const [actualWord, setActualWord] = useState(() => randomDictionaryWord());
// Whether the game is still going
const [isPlaying, setIsPlaying] = useState(true);
// The current word
Expand Down Expand Up @@ -54,6 +55,7 @@ function App() {
setIsPlaying(true);
setBuffer("");
setHistory([]);
setActualWord(randomDictionaryWord());
}}>
Reset
</div>
Expand Down Expand Up @@ -97,4 +99,8 @@ function Letter(props: {
})}>{props.guess}</div>;
}

function randomDictionaryWord() {
return dictionary[Math.floor(Math.random() * dictionary.length)];;
}

export default App;
Loading