Skip to content

committed #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Binary file added .DS_Store
Binary file not shown.
Binary file added 1-exercise-solutions/.DS_Store
Binary file not shown.
Binary file added 1-exercise-solutions/lesson-07/.DS_Store
Binary file not shown.
Empty file.
Binary file added 2-copy-of-code/.DS_Store
Binary file not shown.
40 changes: 40 additions & 0 deletions 2-copy-of-code/duygu/06-rock-paper-scissors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>Rock Paper Scissors</title>
</head>
<body>
<p>Rock Paper Scissors</p>

<button onclick="playGame('rock')">Rock</button>
<button onclick="playGame('paper')">Paper</button>
<button onclick="playGame('scissors')">Scissors</button>

<script>
function getComputerMove() {
const randomNumber = Math.random();
if (randomNumber < 1 / 3) return 'rock';
else if (randomNumber < 2 / 3) return 'paper';
else return 'scissors';
}

function determineWinner(playerMove, computerMove) {
if (playerMove === computerMove) return 'Tie.';
if (
(playerMove === 'rock' && computerMove === 'scissors') ||
(playerMove === 'paper' && computerMove === 'rock') ||
(playerMove === 'scissors' && computerMove === 'paper')
) {
return 'You win!';
}
return 'You lose.';
}

function playGame(playerMove) {
const computerMove = getComputerMove();
const result = determineWinner(playerMove, computerMove);
alert(`You picked ${playerMove}. Computer picked ${computerMove}. ${result}`);
}
</script>
</body>
</html>