title: Removing columns of data in javascript array
body: <p>I have a generated set of data that I've formatted into an array. I need to preserve the initial set of data, but generate a modified array as output in the form of a function, that can then be passed into subsequent functions (to render graph data)</p>
  
  <p>I have an array of data:</p>
  
  <pre><code>dataArray = [
  ['Day', '1', '2', '3', '4', '5', '6'],
  ['Day -7',0,0,0,0,0,0,],
  ['Day -6',0,0,0,0,0,0,],
  ['Day -5',0,0,0,0,0,0,],
  ['Day -4',0,0,0,0,0,0,],
  ['Day -3',0,0,0,0,0,0,],
  ['Day -2',0,0,0,0,0,0,],
                          ];
  </code></pre>
  
  <p>I also setup an array called <code>switch</code></p>
  
  <pre><code>switch = [];
  switch[0] = false;
  switch[1] = false;
  switch[2] = false;
  switch[3] = false;
  switch[4] = false;
  switch[5] = false;
  switch[6] = false;
  </code></pre>
  
  <p>In my code, I loop through the length of the <code>switch</code> array, and I want to remove the corresponding column or index of each line in the array <code>dataArray</code></p>
  
  <pre><code>function workingDataArray(){
      workingArray = null;
      workingArray = dataArray.slice();
      var switchLength = switch.length;
      for (var i = 0; i &lt; switchLength; i++) {
          if(!switch[i]){
              //Remove every item in the position if the switch is true
          }
      }
      return workingArray;
  }
  </code></pre>
  
  <p>The idea here, is that if I change <code>switch[3]</code> and <code>switch[5]</code> to <code>true</code>, it will return:</p>
  
  <pre><code>['Day', '1', '2', '4', '6']
  ['Day -7',0,0,0,0,]
  ['Day -6',0,0,0,0,]
  ['Day -5',0,0,0,0,]
  ['Day -4',0,0,0,0,]
  ['Day -3',0,0,0,0,]
  ['Day -2',0,0,0,0,]
  </code></pre>
  
  <p>I'm not even sure if this is the best way to go about this, but it kind of makes sense to me, but I think I need some help getting in the right direction.</p>