diff --git a/src/wordle/display.svelte b/src/wordle/display.svelte
index 36c3b39..579ca84 100644
--- a/src/wordle/display.svelte
+++ b/src/wordle/display.svelte
@@ -11,11 +11,11 @@
{/each}
- {CurrentWord[0]}
- {CurrentWord[1]}
- {CurrentWord[2]}
- {CurrentWord[3]}
- {CurrentWord[4]}
+ {CurrentWord.v[0]}
+ {CurrentWord.v[1]}
+ {CurrentWord.v[2]}
+ {CurrentWord.v[3]}
+ {CurrentWord.v[4]}
diff --git a/src/wordle/logic.svelte.js b/src/wordle/logic.svelte.js
index 621e542..455bc58 100644
--- a/src/wordle/logic.svelte.js
+++ b/src/wordle/logic.svelte.js
@@ -41,10 +41,29 @@ export let words = $state([
],
]);
-export let CurrentWord = $state([]);
+export let CurrentWord = $state({v:[]});
export function ButtonPressed(key) {
- CurrentWord.push(key);
+ if (key === "↵") {
+ if (CurrentWord.v.length === 5) {
+ let word = CurrentWord.v.join("");
+ if (commonWords.map((entry) => entry.word).includes(word)) {
+ words.push(CurrentWord.v);
+ CurrentWord.v = [];
+ } else {
+ alert("Not a valid word");
+ }
+ }
+ return;
+ } else if (key === "⇦") {
+ CurrentWord.v.pop();
+ return;
+ }
+ if (CurrentWord.v.length === 5) {
+ return;
+ }
+
+ CurrentWord.v.push(key);
}
function getRandomWord() {