title: Discord.js calculate winrate for 2 teams on a list of maps in a video game
body: <p>I'm making a bot that can calculate which of 2 teams have the best win rate on 8 different maps in CSGO.</p>
  <p>I've tried to make a function that can calculate the win rate but I can't extract it into variables for each team. So I can display it in a discord bot. Any ideas on how I can do this?</p>
  <pre><code>const mapPool = [&quot;de_ancient&quot;, &quot;de_dust2&quot;, &quot;de_inferno&quot;, &quot;de_mirage&quot;, &quot;de_nuke&quot;, &quot;de_overpass&quot;, &quot;de_train&quot;, &quot;de_vertigo&quot;];
  
  //displayes absolute winrates. percentdisplay = perc1/(perc1+perc2)*100
  function displayAbsoluteWinrates(){
    for(a = 0; a &lt; mapPool.length; a++){
      perc1 = team1stats[mapPool[a]];
      perc2 = team2stats[mapPool[a]];
      percent1 = (perc1/(perc1+perc2)*100).toFixed(0);
      percent2 = (perc2/(perc1+perc2)*100).toFixed(0);
  
      var team1map = mapPool[a];
  
      //var div1 = document.getElementById(&quot;t1&quot;+mapPool[a]);
      //div1.innerText = percent1+&quot;%&quot;;
  
      //var div2 = document.getElementById(&quot;t2&quot;+mapPool[a]);
      //div2.innerText = percent2+&quot;%&quot;;
  
      if(percent2 &gt; percent1){
        //div1.style.backgroundColor = &quot;red&quot;;
        //div2.style.backgroundColor = &quot;green&quot;;
      }else{
        //div1.style.backgroundColor = &quot;green&quot;;
        //div2.style.backgroundColor = &quot;red&quot;;
      }
      if(percent2 == percent1){
        //div1.style.backgroundColor = &quot;darkorange&quot;;
        //div2.style.backgroundColor = &quot;darkorange&quot;;
      }
    }
  }
  ```
  
  I've rewritten some code that was meant to be for an HTML site into a discord bot.
  
  Sorry if my explanation isn't that good.
  </code></pre>