title: Separate text input that contains commas "," into different array objects
body: <p>When a user inputs the name of the players, I want my code to separate each player into a different object in my array. My code detects when commas &quot;,&quot; are part of the text, but how can I use those commas &quot;,&quot; to separate each player name into an individual object in my array.</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>var subject = [];
  
  function addSubjects() {
  namesInputted = document.getElementById('namesInputter').value;
  
    if (namesInputted.includes(',') == true){
      //HERE IS THE CODE I AM MISSING!!!
    }else{
    subject.push(namesInputted);
    document.getElementById('namesInputter').value = null;
    console.log(subject);
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>  &lt;div class="col-sm-5"&gt;
      &lt;h1&gt;RETOS LOCOS&lt;/h1&gt;
      &lt;input autocomplete="off" class="form-control" type="text" id="namesInputter" placeholder="Player Name" value=""&gt;
      &lt;button type="button" class="btn btn-primary" id="addSubjectsButton" onclick="addSubjects()"&gt;Add Player&lt;/button&gt;
      &lt;button type="button" class="btn btn-primary" id="startGameButton" onclick="startGame()"&gt;Start Game&lt;/button&gt;
      &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>