repl.it
@ssebastianoo/

rockpaperscissorshoe

HTML, CSS, JS

No description

fork
loading
Files
  • index.html
  • script.js
index.html
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!--ORIGINAL CODE: https://repl.it/talk/share/Rock-Paper-Scissors/25775-->

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Rock, Paper, Scissor, Shoe</title>
    <link href="style.css" rel="stylesheet" type="text/css" />

    <style>
      body {
        text-align: center;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 100%;
        font-family: Courier New
      }
    </style>

  </head>
  <body>
    <h1 id = "result"></h1>
    <center><h1 id='demo'></h1></center>
    <center><h1 id='player'></h1></center>
    <center><p id='crack' onclick="yourRoll('Rock')"><button><h1>Rock</h1></button></p></center>
    <center><p id='crack' onclick="yourRoll('Paper')"><button><h1>Paper</h1></button></p></center>
    <center><p id='crack' onclick="yourRoll('Scissor')"><button><h1>Scissors</h1></button></p></center>
    <script>

      

      var player = document.getElementById("player");
      var demo = document.getElementById("demo");
      var result = document.getElementById("result");

      if (player.innerHTML === "Your choice: Paper") {
          if (demo.innerHTML === "I choose: Rock") {
            result.innerHTML = "You Won!"
          }
          if (demo.innerHTML === "I choose: Paper") {
            result.innerHTML = "equality"
          }
          else {
            result.innerHTML = "You Lost!"
          }
      } 

      if (player.innerHTML === "Your choice: Rock") {
          if (demo.innerHTML === "I choose: Scissor") {
            result.innerHTML === "You Won!"
          }
          if (demo.innerHTML === "I choose: Rock") {
            result.innerHTML = "equality"
          }
          else {
            result.innerHTML = "You Lost!"
          }
       }
      if (player.innerHTML === "Your choice: Scissor") {
          if (demo.innerHTML === "I choose: Paper") {
            result.innerHTML === "You Won!"
          }
          if (demo.innerHTML === "I choose: Scissor") {
            result.innerHTML = "equality"
          }
          else {
            result.innerHTML = "You Lost!"
          }
      }
    
      function oppRoll() {
        elements = ["Rock", "Paper", "Scissor"]

        var r = Math.floor(Math.random() * elements.length);
        document.getElementById("demo").innerHTML = `I choose: ${elements[r]}`
      }

      function yourRoll(rolltype) {
        document.getElementById('player').innerHTML = `Your choice: ${rolltype}`;
        oppRoll()
      }

    </script>
  </body>
</html>
result
console
?