diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-04-18 15:05:29 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-04-18 15:05:29 +0800 |
commit | 6afec66256e9e9c6cc28016fc03d73970abc792b (patch) | |
tree | decccd7847a627b4220b3c764966f8a1b6175f9f | |
parent | 29aa3eac1900406decadf70f1d4cee15c13efd88 (diff) |
Notify when there is no word left
-rw-r--r-- | index.js | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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 |