Still waiting for the New York Times to send me a bogus takedown notice
Remove debug console.log() call
Saksham Mittal 2022-04-02
parent 4a172ea · commit ef2f28d
-rw-r--r--script.js13
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;
- }
+
}
}
}