title: How can I handle my array in a better way?
body: <p>I'm creating a minigame in Discord, which collects players - creates an array out of participants and then starts to kill them one by one until only one survivor is left. However I'm having a weird problem where most of the time winner emerges, but sometimes it does not. I've been trying to figure this out, even though about making a feature out of it at first - but then again - I'd like to know where I've done the mistake. Here's the code:</p>
  <pre class="lang-js prettyprint-override"><code>function StartGame(array, runner) {
  
    message.channel.send(&quot;**THE GAME HAS STARTED**&quot;);
  
    let amountOfDays = array.length - 1;
    let dailyDeaths = [];
  
    for (let MainLoop = 0; MainLoop &lt; amountOfDays; MainLoop++) {
  
      let rando = array[Math.floor(Math.random() * array.length)];
  
      dailyDeaths.push(rando);
  
      let newarray = [];
  
      for (let i = 0; i &lt; array.length; i++) {
        if (array[i] != rando) {
          newarray.push(array[i]);
        }
      }
  
      array = newarray;
    }
  
    let winnerOfTheRace = array.join(&quot;, &quot;);
    if (winnerOfTheRace) {
      runner.send(&quot;**runner debug** - Everything calculated (winner is going to be **&quot; + winnerOfTheRace + &quot;**). Launching the game.&quot;);
    } else {
      runner.send(&quot;**runner debug** - Everything calculated (no winner - this is the error here.).&quot;);
    }
    
    LoopThroughTheGame(dailyDeaths, winnerOfTheRace);
  
    return;
  }
  </code></pre>
  <p>The <code>.join(&quot;,&quot;)</code> in <code>winnerOfTheRace</code> setting is if I want to set up multiple winners in the future. But at the moment I expect it to return only one name. And it usually does. Randomly doesn't. What am I doing wrong? :D</p>