sdds
This commit is contained in:
parent
433c13f4ac
commit
6cae0e6b23
2 changed files with 26 additions and 7 deletions
|
@ -11,11 +11,11 @@
|
|||
</div>
|
||||
{/each}
|
||||
<div class="word">
|
||||
<span>{CurrentWord[0]}</span>
|
||||
<span>{CurrentWord[1]}</span>
|
||||
<span>{CurrentWord[2]}</span>
|
||||
<span>{CurrentWord[3]}</span>
|
||||
<span>{CurrentWord[4]}</span>
|
||||
<span>{CurrentWord.v[0]}</span>
|
||||
<span>{CurrentWord.v[1]}</span>
|
||||
<span>{CurrentWord.v[2]}</span>
|
||||
<span>{CurrentWord.v[3]}</span>
|
||||
<span>{CurrentWord.v[4]}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue