From 1a8add76d8f8cd54105bcda1c833af4512c79719 Mon Sep 17 00:00:00 2001 From: NetMan <13informatyka14@gmail.com> Date: Wed, 3 Jan 2024 21:56:57 +0100 Subject: [PATCH] Added start game button Now the game does not start automatically and there's no need to refresh --- index.html | 19 +++++++++++++++++++ index.js | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 4474fa8..9edcc8d 100644 --- a/index.html +++ b/index.html @@ -4,8 +4,27 @@ Rock Paper Scissors + + \ No newline at end of file diff --git a/index.js b/index.js index 13fe3aa..ac194c4 100644 --- a/index.js +++ b/index.js @@ -43,7 +43,8 @@ const points = (() => { playerAddPoints, computerAddPoints, reset}; })() -function game() { +function game(clickEvent) { + clickEvent.setAttribute('onclick', ' '); points.reset(); for (let i = 0; i < 5; i++) { @@ -60,6 +61,7 @@ function game() { } }) } else if (confirm(`Do you wanna quit the game?`)) { + clickEvent.setAttribute('onclick', 'game(this)'); throw new Error("Exited the game on user's request"); } } @@ -82,4 +84,4 @@ function game() { } } -game(); \ No newline at end of file +// game(); \ No newline at end of file