diff --git a/Rock Paper Scissor/0.jpg b/Rock Paper Scissor/0.jpg new file mode 100644 index 0000000..7f10f6d Binary files /dev/null and b/Rock Paper Scissor/0.jpg differ diff --git a/Rock Paper Scissor/1.jpg b/Rock Paper Scissor/1.jpg new file mode 100644 index 0000000..9a2a08a Binary files /dev/null and b/Rock Paper Scissor/1.jpg differ diff --git a/Rock Paper Scissor/2.jpg b/Rock Paper Scissor/2.jpg new file mode 100644 index 0000000..4a5fbfc Binary files /dev/null and b/Rock Paper Scissor/2.jpg differ diff --git a/Rock Paper Scissor/index.html b/Rock Paper Scissor/index.html new file mode 100644 index 0000000..2fe06fb --- /dev/null +++ b/Rock Paper Scissor/index.html @@ -0,0 +1,22 @@ + + + + + + Rock Paper Scissor + + + +

Rock Paper Scissor

+

Select your choice

+
+ + + +
+

+

+

+ + + \ No newline at end of file diff --git a/Rock Paper Scissor/script.js b/Rock Paper Scissor/script.js new file mode 100644 index 0000000..9cdda8b --- /dev/null +++ b/Rock Paper Scissor/script.js @@ -0,0 +1,26 @@ +const choice = document.querySelectorAll('button') +choice.forEach(choice => choice.addEventListener('click',result)); + +function result(id){ + const ai = Math.floor(Math.random()*3) + console.log(id.target) + const player =Number(id.target.id) + const arr = ['Rock','Paper','Scissor'] + document.getElementById("your-answer").innerText = "YOU : "+arr[player] + document.getElementById("ai-answer").innerText = "AI : "+arr[ai] + console.log(ai,player) + if(ai == player) + document.getElementById("Result").innerText = "DRAW" + if(ai ==0 && player ==1) + document.getElementById("Result").innerText = "YOU WON!" + else if(ai ==0 && player ==2) + document.getElementById("Result").innerText = "YOU LOST!" + if(ai ==1 && player ==2) + document.getElementById("Result").innerText = "YOU WON!" + else if(ai ==1 && player ==0) + document.getElementById("Result").innerText = "YOU LOST!" + if(ai ==2 && player ==0) + document.getElementById("Result").innerText = "YOU WON!" + else if(ai ==2 && player ==1) + document.getElementById("Result").innerText = "YOU LOST!" +} \ No newline at end of file diff --git a/Rock Paper Scissor/styles.css b/Rock Paper Scissor/styles.css new file mode 100644 index 0000000..57dd07f --- /dev/null +++ b/Rock Paper Scissor/styles.css @@ -0,0 +1,9 @@ +body{ + font-family:Arial, Helvetica, sans-serif; + text-align: center; + background-color: rgba(148, 184, 117, 0.804); +} +button{ + padding: 0; + margin: 10px; +}