From 9fa14ccf093a7e56b1e780e83f02042ceff25bce Mon Sep 17 00:00:00 2001
From: Synobbol <97944378+Synobbol@users.noreply.github.com>
Date: Tue, 17 Jan 2023 14:40:08 +0100
Subject: [PATCH] Create computer's choice
---
index.html | 14 ++++++++++++++
script.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+)
create mode 100644 index.html
create mode 100644 script.js
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..828467c
--- /dev/null
+++ b/index.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ Rock Paper Scissors
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/script.js b/script.js
new file mode 100644
index 0000000..b2cb120
--- /dev/null
+++ b/script.js
@@ -0,0 +1,50 @@
+//1.function called getComputerChoice
+//that will randomly return either ‘Rock’, ‘Paper’ or ‘Scissors’.
+
+//2.function that plays a single round of Rock Paper Scissors.
+//The function should take two parameters - the playerSelection and computerSelection -
+//and then return a string that declares the winner of the round like so:
+//"You Lose! Paper beats Rock"
+//Make your function’s playerSelection parameter case-insensitive
+//(so users can input rock, ROCK, RocK or any other variation).
+
+//3.Important note: you want to return the results of this function call, not console.log() them.
+//You’re going to use what you return later on,
+//so let’s test this function by using console.log to see the results:
+
+//4.Write a NEW function called game().
+//Call the playRound function inside of this one to play a 5 round game
+//that keeps score and reports a winner or loser at the end.
+//At this point you should be using console.log() to display
+//the results of each round and the winner at the end.
+//Use prompt() to get input from the user. Read the docs here if you need to.
+//Feel free to re-work your previous functions if you need to.
+//Specifically, you might want to change the return value to something more useful.
+//Feel free to create more “helper” functions if you think it would be useful.
+
+function getComputerChoice(){
+ const number = Math.floor(Math.random() * 3);
+ let computer = number;
+
+ if (number === 0){
+ computer = "rock";
+ }
+ else if (number === 1){
+ computer= "paper";
+ }
+ else{
+ computer= "scissors";
+ }
+
+ return computer;
+}
+
+console.log(getComputerChoice());
+
+function playRound(playerSelection, computerSelection){
+ if (playerSelection = "rock" && computerSelection == "paper"){
+
+ }
+ else if(playerSelection = "paper" && computerSelection == "scissors")
+ //"You Lose! Paper beats Rock"
+}
\ No newline at end of file