From 9a277d9d7c48c03772d042104ea2e04d5bde037b Mon Sep 17 00:00:00 2001 From: mahakagarwal7 Date: Tue, 28 Oct 2025 07:18:52 +0530 Subject: [PATCH 1/3] Added my project: Rock-Paper-Scissors Game --- rock-paper-scissors/README.md | 17 +++++++++++++++ rock-paper-scissors/index.html | 18 ++++++++++++++++ rock-paper-scissors/script.js | 38 ++++++++++++++++++++++++++++++++++ rock-paper-scissors/style.css | 26 +++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 rock-paper-scissors/README.md create mode 100644 rock-paper-scissors/index.html create mode 100644 rock-paper-scissors/script.js create mode 100644 rock-paper-scissors/style.css diff --git a/rock-paper-scissors/README.md b/rock-paper-scissors/README.md new file mode 100644 index 0000000..597c0e3 --- /dev/null +++ b/rock-paper-scissors/README.md @@ -0,0 +1,17 @@ +Rock Paper Scissors Game:- +A simple Rock, Paper, Scissors game where you play against the computer! Designed for beginners using only basic HTML, CSS, and JavaScript (loops, functions, and variables).​ + +Features:- +Play Rock, Paper, Scissors against a computer opponent.​ + +Easy-to-read, beginner-friendly code structure. + +Game Rules:- +Rock beats Scissors + +Scissors beats Paper + +Paper beats Rock + +If both you and the computer choose the same option, it’s a tie. + diff --git a/rock-paper-scissors/index.html b/rock-paper-scissors/index.html new file mode 100644 index 0000000..ee0793d --- /dev/null +++ b/rock-paper-scissors/index.html @@ -0,0 +1,18 @@ + + + + + Rock Paper Scissors + + + +

Rock Paper Scissors

+
+ + + +
+

+ + + diff --git a/rock-paper-scissors/script.js b/rock-paper-scissors/script.js new file mode 100644 index 0000000..5f6d8dd --- /dev/null +++ b/rock-paper-scissors/script.js @@ -0,0 +1,38 @@ +function play(playerChoice) { + var choices = ['rock', 'paper', 'scissors']; + var computerChoice = choices[Math.floor(Math.random() * 3)]; + var result = ''; + + if (playerChoice === computerChoice) { + result = "It's a tie! You both chose " + playerChoice + "."; + } else if ( + (playerChoice === 'rock' && computerChoice === 'scissors')|| + (playerChoice === 'paper' && computerChoice === 'rock')|| + (playerChoice === 'scissors' && computerChoice === 'paper') + ) { + result = "You win! " + playerChoice + " beats " + computerChoice + "."; + } else { + result = "You lose! " + computerChoice + " beats " + playerChoice + "."; + } + + document.getElementById('result').textContent = result; +} +function play(playerChoice) { + var choices = ['rock', 'paper', 'scissors']; + var computerChoice = choices[Math.floor(Math.random() * 3)]; + var result = ''; + + if (playerChoice === computerChoice) { + result = "It's a tie! You both chose " + playerChoice + "."; + } else if ( + (playerChoice === 'rock' && computerChoice === 'scissors') || + (playerChoice === 'paper' && computerChoice === 'rock') || + (playerChoice === 'scissors' && computerChoice === 'paper') + ) { + result = "You win! " + playerChoice + " beats " + computerChoice + "."; + } else { + result = "You lose! " + computerChoice + " beats " + playerChoice + "."; + } + + document.getElementById('result').textContent = result; +} diff --git a/rock-paper-scissors/style.css b/rock-paper-scissors/style.css new file mode 100644 index 0000000..ea16f94 --- /dev/null +++ b/rock-paper-scissors/style.css @@ -0,0 +1,26 @@ +body { + font-family: Arial, sans-serif; + text-align: center; + margin-top: 50px; + background: #e5eeff; +} + +button { + padding: 12px 24px; + margin: 10px; + font-size: 18px; + border-radius: 8px; + border: none; + background: #4973ab; + color: white; + cursor: pointer; +} +button:hover { + background: #395986; +} + +#result { + font-size: 22px; + margin-top: 30px; + color: #222; +} From d6a3ffaeb89e4933f556bd96307bb483e733b201 Mon Sep 17 00:00:00 2001 From: mahakagarwal7 Date: Tue, 28 Oct 2025 07:33:02 +0530 Subject: [PATCH 2/3] Fix CSS filename in HTML from styles.css to style.css --- rock-paper-scissors/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rock-paper-scissors/index.html b/rock-paper-scissors/index.html index ee0793d..db469e8 100644 --- a/rock-paper-scissors/index.html +++ b/rock-paper-scissors/index.html @@ -3,7 +3,7 @@ Rock Paper Scissors - +

Rock Paper Scissors

From 9acc1c30d7115d8c41a718e24ec7ad5d2269997d Mon Sep 17 00:00:00 2001 From: mahakagarwal7 Date: Tue, 28 Oct 2025 07:39:28 +0530 Subject: [PATCH 3/3] Fix script.js file --- rock-paper-scissors/script.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/rock-paper-scissors/script.js b/rock-paper-scissors/script.js index 5f6d8dd..e558760 100644 --- a/rock-paper-scissors/script.js +++ b/rock-paper-scissors/script.js @@ -17,22 +17,4 @@ function play(playerChoice) { document.getElementById('result').textContent = result; } -function play(playerChoice) { - var choices = ['rock', 'paper', 'scissors']; - var computerChoice = choices[Math.floor(Math.random() * 3)]; - var result = ''; - if (playerChoice === computerChoice) { - result = "It's a tie! You both chose " + playerChoice + "."; - } else if ( - (playerChoice === 'rock' && computerChoice === 'scissors') || - (playerChoice === 'paper' && computerChoice === 'rock') || - (playerChoice === 'scissors' && computerChoice === 'paper') - ) { - result = "You win! " + playerChoice + " beats " + computerChoice + "."; - } else { - result = "You lose! " + computerChoice + " beats " + playerChoice + "."; - } - - document.getElementById('result').textContent = result; -}