title: Can you check if separate parts of your array are equal?
body: <p>I'm making a tic-tac-toe game and am checking the values of the winning arrays after each turn. If one of these arrays match then that player wins the game. My question is, are you able to check if the values of separate pieces of an array are equal in this manner?</p>
  
  <pre><code> function winner(){
          var blocks = document.getElementsByClassName('block');
      for (var i = 0; i &lt; blocks.length; i++) {
          if(blocks[0,1,2].value=='X' || blocks[0,3,6].value=='X' || blocks[2,5,8].value=='X' || blocks[6,7,8].value=='X' || blocks[2,4,6].value=='X' || blocks[0,4,8].value=='X'){
              alert('Player X Wins!!');
              blocks.classList.toggle('block');
              player===1;
          }
      };
  
          var blocks = document.getElementsByClassName('block');
      for (var i = 0; i &lt; blocks.length; i++) {  
          if(blocks[0,1,2].value=='O' || blocks[0,3,6].value=='O' || blocks[2,5,8].value=='O' || blocks[6,7,8].value=='O' || blocks[2,4,6].value=='O' || blocks[0,4,8].value=='O'){
              alert('Player O Wins!!');
              blocks.classList.toggle('block');
              player===1;
          }
  
          }
              }
  </code></pre>
  
  <p>Also would this method of class switching work? I'm trying to switch to a different class indicating the selected block whenever it is either clicked or selected randomly by the computer.</p>
  
  <pre><code>var player===1
  
  var blocks = document.getElementsByClassName('block');
  
  function turn(){
      if(player===1){
      player-=1;
      winner();
  var  buttons= document.getElementsByTagName("button");
  console.log(buttons.length);
  for (var i = 0; i &lt; buttons.length; i++) {
      buttons[i].addEventListener("click", function(e) {
          var number=(this.getAttribute('name'));
          var chosenblock=document.getElementsByName(number)[0];
          chosenblock.classList.toggle('chosen');
          chosenblock.value='X';
         // console.log('click!');
      });
  }
      }
  
      else{
          player+=1;
          winner();
      var computer;
  computer = function () {
      var computerchoice=Math.floor(Math.random()*(9)+1);
      function compselected(number) {
          //How to make number equal to the id of the selected block?
          var chosenblock = document.getElementsByName(number)[0];
          chosenblock.classlist.toggle('picked');
  </code></pre>
  
  <p>I had it working before I started playing with it, any help would be appreciated! Here is the <a href="http://jsfiddle.net/Zach94/e6dsr3ot/" rel="nofollow">fiddle</a> if you want more detail.</p>