diff --git a/Games/Am_I_the_number/README.md b/Games/Am_I_the_number/README.md index ea438575c0..101e80d064 100644 --- a/Games/Am_I_the_number/README.md +++ b/Games/Am_I_the_number/README.md @@ -12,6 +12,11 @@ - enter a number in the guess field and press submit to check whether the number you thought of matches the number. +## New Feature +- Added Restart button to reset the game without refreshing. + + +
diff --git a/Games/Am_I_the_number/index.html b/Games/Am_I_the_number/index.html index fe4f530726..7b73511cbb 100644 --- a/Games/Am_I_the_number/index.html +++ b/Games/Am_I_the_number/index.html @@ -17,6 +17,7 @@

Number guessing game

Think of a number +

Previous guesses:

diff --git a/Games/Am_I_the_number/script.js b/Games/Am_I_the_number/script.js index e7430dcaaf..e518a476ad 100644 --- a/Games/Am_I_the_number/script.js +++ b/Games/Am_I_the_number/script.js @@ -94,4 +94,14 @@ document.addEventListener('DOMContentLoaded', function () { }); } }); + + + function resetGame() { + target = Math.floor(Math.random() * 100) + 1; // regenerate number + document.getElementById("guess").value = ""; // clear input + document.getElementById("status").textContent = "Game restarted! Guess a number between 1 and 100."; + } + + document.getElementById("restart").addEventListener("click", resetGame); + \ No newline at end of file diff --git a/assets/images/Am_I_the_number.png b/assets/images/Am_I_the_number.png new file mode 100644 index 0000000000..3e4481c4b7 Binary files /dev/null and b/assets/images/Am_I_the_number.png differ