summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-04-18 15:05:29 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-04-18 15:05:29 +0800
commit6afec66256e9e9c6cc28016fc03d73970abc792b (patch)
treedecccd7847a627b4220b3c764966f8a1b6175f9f
parent29aa3eac1900406decadf70f1d4cee15c13efd88 (diff)
Notify when there is no word left
-rw-r--r--index.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/index.js b/index.js
index cfda479..95dd341 100644
--- a/index.js
+++ b/index.js
@@ -15,6 +15,13 @@ let currentWord = {};
let hintTaken = false;
function newWord() {
+ if (WORDS.length == 0) {
+ // what the hell
+ // why would anyone click Next 1005 times
+ wordElem.innerHTML = "There are no more words."
+ return;
+ }
+
const idx = Math.floor(Math.random() * WORDS.length);
currentWord = WORDS[idx];
WORDS.splice(idx, 1); // remove word from WORDS so it will not show again