title: JavaScript finding matching values in a for loop
body: <p>The array is sorted in an increasing order and I would like to get the values of the matching ones separated by a colon. </p>
  
  <pre><code>var array = [1, 1, 2, 2, 2, 3, 4, 5, 5, 5, 5];
  var text = "";
  
  for(var i = 0; i &lt; array.length - 1; i++) {
      if(array[0] == array[0 + 1]) {
           text = array[0] + ":" + array[0 + 1]; // 1:1
      }
  }
  </code></pre>
  
  <p>This for-loop only checks for two matching values. How would I check for all the number of matching values?</p>
  
  <p>So for 1, the text would be 1:1<Br>
  for 2, the text would be 2:2:2<Br>
  for 5, the text would be 5:5:5:5</p>