title: Checking for two consecutive values match of a variable's value in JavaScript
body: <p>I built a function called <code>roll()</code> which handles a roll of a dice. I'm trying to read the value of the roll and check if the roll hit 6 twice in a row so that I can interrupt the player's turn and turn it to the next player.</p>
  
  <p>I can read the dice value alright, I'm having trouble trying to figure out how to check for a 6 twice in a row.</p>
  
  <p>This is my function:</p>
  
  <pre><code> roll = function(){
      if (gamePlaying){
          // 1. Get a random number
          //var dice = Math.floor(Math.random() * 6) + 1; //1 to 6 randomly
          var dice = 6;
  
          //2. Display the result
          var diceDOM = document.querySelector('.dice');
          diceDOM.style.display = 'block';
          diceDOM.src = 'images/' + 'dice-' + dice + '.png';
  
          //3. Update the roundScore IF the rolled number is not 1
  
          // for type coersion, we need to use !== and not !=
          if(dice !== 1) {
              //add score
              roundScore += dice; // same as roundScore = roundScore + dice
              //it outputs to a div of ID = #myId
              document.querySelector('#current-' + activePlayer).textContent = roundScore;
          } else {
              alert('Next Player')
              nextPlayer();
          }
  
          // Is this right?
          for(var i = 1; i &gt;= 2; i++){
              if (dice == 6){
                  console.log('sixes');
              }
          }
  
      }
  }
  </code></pre>
  
  <p>Being triggered by a button like this:</p>
  
  <pre><code>document.querySelector('.btn-roll').addEventListener('click', function(){
      roll();
  
  });
  </code></pre>
  
  <p>I loaded the game to this <a href="http://codepen.io/LOTUSMS/pen/aBLNvr" rel="nofollow noreferrer"><strong>CODEPEN</strong></a></p>
  
  <p>P.S. I put a <code>dice = 6;</code> under the random function so you don't have to play the game until you get two sixes. Just uncomment it and comment out the dice = math function and you'll get nothing but sixes.</p>
  
  <p>I also put a "Is this right?" comment on top of a for loop. What I mean by that is, " is this the right approach?" Should I keep experimenting with a loop or am I way off already?</p>
  
  <p>And by the way, if 2 sixes do come up, the entire score is deleted which is being passed to the <code>score[]</code> But I can do that... I think lol</p>
  
  <p>Many thanks.</p>