title: Checking by not restricting how many elements
body: <p>I want to make it like for example when the word spilt into elements, the checking part will not restrict to only four.(In code comment it as "this part"). I want to be depending on how many the elements split so that it will be correct. </p>
  
  <pre><code> if(original[0]==$("#box1").text()&amp;&amp;original[1]==$("#box2").text()&amp;&amp;original[2]==$("#box3").text()&amp;&amp;original[3]==$("#box4").text())
  </code></pre>
  
  <p>This only restricted to four, then the checking will be correct. How can I do it such as there will be three split elements or more then four elements and the checking will still be correct.</p>
  
  <pre><code>&lt;script&gt;
  js_var = "&lt;?php echo $output ?&gt;";
  var c = ['c1','c2','c3','c4','c5','c6','c7','c8','c9','c10'];
  var div_id = ['id1','id2','id3','id4','id5','id6','id7','id8','id9','id10'];
  var box_id = ['box1','box2','box3','box4','box5','box6','box7','box8','box9','box10'];
  var original = js_var.split("#");
  var balls90= js_var.split("#");
  
  
  var x = document.getElementById("demo");
  for (var i=0; i &lt; original.length; i++) {
  var el = document.createElement('div');
  el.id = c[i];
  el.innerHTML = original[i];
  x.appendChild(el);
  }
  
  
  function getNumbers() {
  var player1 = new Array();
  balls90.sort(function() {
      return Math.random() - .25;
      document.getElementById("shuffle").onclick = function(){displayDate()};
  });
  
   for (var i = 0; i &lt; balls90.length; i++) {
       document.writeln('&lt;div id='+box_id[i]+' class=box droppable=true ondrop=drop(event)     
  ondragover=allowDrop(event)&gt;&lt;/div&gt;');
   }
  
  
  for (var i = 0; i &lt; balls90.length; i++) {
      player1.push(balls90[i]);
  
  
      document.writeln('&lt;div id='+div_id[i]+' draggable=true droppable=true 
  ondragstart=drag(event)&gt;'+balls90[i]+'&lt;/div&gt;');
  
   }
  
  }
  
  getNumbers();
  
  
  function dragWord(dragEvent){
  dragEvent.dataTransfer.setData("text/html",     
  dragEvent.target.textContent+"|"+dragEvent.target.parentNode.id);
  }
  
  
  function dropWord(dropEvent){
  var dropData = dropEvent.dataTransfer.getData("text/html");
  var dropItems = dropData.split("|");
  var prevElem = document.getElementById(dropItems[1]);
  prevElem.getElementsByTagName("div")[0].textContent = dropEvent.target.textContent;
  dropEvent.target.textContent = dropItems[0];
  dropEvent.preventDefault();
  }
  
  function allowDrop(ev) {
  ev.preventDefault();
  }  
  
  
  function drag(ev) {
      ev.dataTransfer.setData("Text", ev.target.id);
  }
  
  function drop(ev) {
      ev.preventDefault();
      var data = ev.dataTransfer.getData("Text");
      ev.target.appendChild(document.getElementById(data));
  
   //this part
  
  if(original[0]==$("#box1").text()&amp;&amp;original[1]==$("#box2").text()&amp;&amp;original[2]==$("#box3").text()&amp;&amp;original[3]==$("#box4").text())
      {
          alert('correct');
      }
  
  }
  &lt;script&gt;
  </code></pre>