title: I've created this simple JS dice game where I run 2 dice
body: <p>I want to hear suggestions on how to improve this code, there's probably a way that I can call the same function to get 2 different results? When I tried that, I got 2 dices printing the same result. Any other suggestion on how to make this look better would be nice.</p>
  <p>I already figured out how to do it by using only the <code>dice1</code> and <code>dice2</code> since a function is not required for that and printing it to the console, now I want to use 2 functions because I want to do this silly ASCII art thing.</p>
  <p>Is there a way that instead of calling</p>
  <pre><code>diceSpin();
  diceSpin2();
  </code></pre>
  <p>I just call a <code>diceSpin(dice1, dice2)</code> and get the same output?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const diceResult = Math.floor(Math.random() * 6) + 1;
  const diceResult2 = Math.floor(Math.random() * 6) + 1;
  console.log("Dice 1: " + diceResult + "     Dice 2: " + diceResult2)
  
  function diceSpin() {
    if (diceResult === 1) {
      console.log(" .......")
      console.log("|       |")
      console.log("|   o   |")
      console.log("|       |")
      console.log(" ''''''' ")
    } else if (diceResult === 2) {
      console.log(" .......")
      console.log("|       |")
      console.log("| o   o |")
      console.log("|       |")
      console.log(" ''''''' ")
    } else if (diceResult === 3) {
      console.log(" .......")
      console.log("|       |")
      console.log("| o o o |")
      console.log("|       |")
      console.log(" ''''''' ")
    } else if (diceResult === 4) {
      console.log(" .......")
      console.log("| o   o |")
      console.log("|       |")
      console.log("| o   o |")
      console.log(" ''''''' ")
    } else if (diceResult === 5) {
      console.log(" .......")
      console.log("| o   o |")
      console.log("|   o   |")
      console.log("| o   o |")
      console.log(" ''''''' ")
    } else {
      console.log(" .......")
      console.log("| o o o |")
      console.log("| o o o |")
      console.log("| o o o |")
      console.log(" ''''''' ")
    }
  }
  
  function diceSpin2() {
    if (diceResult2 === 1) {
      console.log(" .......")
      console.log("|       |")
      console.log("|   o   |")
      console.log("|       |")
      console.log(" ''''''' ")
    } else if (diceResult2 === 2) {
      console.log(" .......")
      console.log("|       |")
      console.log("| o   o |")
      console.log("|       |")
      console.log(" ''''''' ")
    } else if (diceResult2 === 3) {
      console.log(" .......")
      console.log("|       |")
      console.log("| o o o |")
      console.log("|       |")
      console.log(" ''''''' ")
    } else if (diceResult2 === 4) {
      console.log(" .......")
      console.log("| o   o |")
      console.log("|       |")
      console.log("| o   o |")
      console.log(" ''''''' ")
    } else if (diceResult2 === 5) {
      console.log(" .......")
      console.log("| o   o |")
      console.log("|   o   |")
      console.log("| o   o |")
      console.log(" ''''''' ")
    } else {
      console.log(" .......")
      console.log("| o o o |")
      console.log("| o o o |")
      console.log("| o o o |")
      console.log(" ''''''' ")
    }
  }
  diceSpin();
  diceSpin2();
  
  if (diceResult &gt; diceResult2) {
    console.log("Dice 1 wins!")
  } else if (diceResult &lt; diceResult2) {
    console.log("Dice 2 wins!")
  } else {
    console.log("Draw!")
  }</code></pre>
  </div>
  </div>
  </p>