diff options
| author | Saksham Mittal <gotlouemail@gmail.com> | 2022-04-02 21:13:54 +0530 |
|---|---|---|
| committer | Saksham Mittal <gotlouemail@gmail.com> | 2022-04-02 21:13:54 +0530 |
| commit | ef2f28db550ece88361573cd8835458e7bb49f88 (patch) | |
| tree | 7f58f40b2eb5db1bfea17c39e43e43e257067c62 | |
| parent | 4a172ea5c9ae912f465444b60981437d8edf3637 (diff) | |
| download | purple-ef2f28db550ece88361573cd8835458e7bb49f88.tar.gz | |
Remove debug console.log() call
| -rw-r--r-- | script.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/script.js b/script.js index 3f2d22e..be7a2f6 100644 --- a/script.js +++ b/script.js @@ -52,7 +52,6 @@ function validateInput() { for (var i = 0; i < len; i++) { let c = input.value.charAt(i) if (c.toUpperCase() == c.toLowerCase()) { - console.log("hi"); isvalid = false; break; } @@ -65,10 +64,12 @@ function validateInput() { function checkAnswer(event) { event.preventDefault(); + if (!exit) { if (validateInput()) { addGuessDisplay(); + tries++; if (input.value == answer) { @@ -77,16 +78,16 @@ function checkAnswer(event) { } else { win.innerHTML = "Not quite right!"; } - + if (tries >= maxtries && !exit) { + win.innerHTML = "You lost! Better luck next time!"; + exit = true; + } attempt.innerHTML = tries + " attempt"; if (tries > 1) { attempt.innerHTML += "s"; } - if (tries > maxtries) { - win.innerHTML = "You lost! Better luck next time!"; - exit = true; - } + } } } |
