about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--script.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/script.js b/script.js
index 43ab097..3f2d22e 100644
--- a/script.js
+++ b/script.js
@@ -1,4 +1,5 @@
 let answer = "hello";
+let maxtries = 6;
 let len = answer.length;
 
 let input = document.querySelector('input');
@@ -69,6 +70,7 @@ function checkAnswer(event) {
 		if (validateInput()) {
 			addGuessDisplay();
 			tries++;
+			
 			if (input.value == answer) {
 				win.innerHTML = "You won!";
 				exit = true;
@@ -80,6 +82,11 @@ function checkAnswer(event) {
 			if (tries > 1) {
 				attempt.innerHTML += "s";
 			}
+
+			if (tries > maxtries) {
+				win.innerHTML = "You lost! Better luck next time!";
+				exit = true;
+			}
 		}
 	}
 }