Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions rock-paper-scissors/README.md
Original file line number Diff line number Diff line change
@@ -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.

18 changes: 18 additions & 0 deletions rock-paper-scissors/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rock Paper Scissors</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Rock Paper Scissors</h1>
<div id="buttons">
<button onclick="play('rock')">Rock</button>
<button onclick="play('paper')">Paper</button>
<button onclick="play('scissors')">Scissors</button>
</div>
<p id="result"></p>
<script src="script.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions rock-paper-scissors/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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;
}

26 changes: 26 additions & 0 deletions rock-paper-scissors/style.css
Original file line number Diff line number Diff line change
@@ -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;
}
Loading