-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
34 lines (28 loc) · 1.05 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function getComputerChoice(){
let choices=['Rock','Paper', 'Scissors']
return choices[Math.floor(Math.random()*choices.length)];
}
function getPlayerChoice(){
let playerSelection = prompt("Rock, Paper, or Scissors?")
}
function rockPaperScissors(playerSelection, computerSelection){
computerSelection = getComputerChoice().toLowerCase;
playerSelection = playerSelection.toLowerCase;
if(
(computerSelection === 'rock' && playerSelection === 'scissors') ||
(computerSelection === 'paper' && playerSelection === 'rock') ||
(computerSelection === 'scissors' && playerSelection === 'paper')
) {
return ("Computer wins!");
}
else if(
(computerSelection === 'rock' && playerSelection ==='paper') ||
(computerSelection === 'paper' && playerSelection === 'scissors') ||
(computerSelection === 'scissors' && playerSelection === 'rock')
) {
return ("Player wins!");
}
else if(computerSelection===playerSelection) {
return ("It's a tie!");
}
}