title: How to find duplicates of three variables that reference an array?
body: <p>I have a function that reads a txt file and then creates three variables from a combination of <code>charAt()</code> values for each line that it reads. The variables are k, k1, and k2. These variables reference a very long array file <code>myarray[k][k1][k2]</code> and then writes the value of these array elements to a <code>div</code>.</p>
  
  <p>I may be reading up to 400 lines of text and each time the k, k1, and k2 values are created. How would I go about determining if these same k, k1, and k2 values are being duplicated?"</p>
  
  <p>Update - I tried using </p>
  
  <pre><code>if ( !(myArray[k] &amp;&amp; myArray[k][k1] &amp;&amp; myArray[k][k1][k2]))
  </code></pre>
  
  <p>but it did not work, probably because I did not explain my problem properly.</p>
  
  <p>For example, after reading, say line 15, I get values of <code>k=0, k1=3, k2=10</code> and these are the values that will be used for <code>myArray[k][k1][k2]</code></p>
  
  <p>These same values, i.e. <code>k=0, k1=3, k2=10</code> may not occur again, or they may occur after reading, say line 222 and if this is the case, I want to write something different, i.e. I don't want to output the value of <code>myArray[0][3][10]</code> again.
  I hope this makes sense.</p>
  
  <p>I think it is best if I include code:</p>
  
  <pre><code>    &lt;script src="AllTransit.js"&gt;&lt;/script&gt;
  
  
  &lt;script&gt;
  
  var myplanets = 
  ["SUN    ", "MOON   ", "MERCURY", "VENUS  ", "MARS   ", "JUPITER", "SATURN ", "URANUS ", "NEPTUNE",     "PLUTO  "]
  
  var myplanets1 = 
  ["SUN    ", "MOON   ", "MERCURY", "VENUS  ", "MARS   ", "JUPITER", "SATURN ", "URANUS   ", "NEPTUNE",   "PLUTO  ", "MC     ", "ASC    "]
  
  var myaspects = ["conjunct", "sextile ", "square  ", "trine   ", "opposite"]
  
  var numval =  [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  var numval1 = [0, 1, 2, 3, 4]
  var numval2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
  
  var r, tplanet, aspect, nplanet, range, k, k1, k2
  
  
  
  function loadFile(){
  
    var ForReading = 1, ForWriting = 2, ForAppending = 8;
    var fso = new ActiveXObject("Scripting.FileSystemObject");
  
    var filename = "emmy_test1.txt"
    var info = document.getElementById("info");
    var transits = document.getElementById("transits");
  
    f = fso.OpenTextFile(filename, ForReading);
  
  
    while (!f.AtEndOfStream){
      r = f.ReadLine();
  
      tplanet  =  r.charAt(2) + r.charAt(3) + r.charAt(4) + r.charAt(5) + r.charAt(6) + r.charAt(7) + r.charAt    (8)
  
      for (var j = 0; j &lt; myplanets.length; j++) {
        if (tplanet==myplanets[j]) {k = numval[j]}
      }
  
      aspect = r.charAt(34) + r.charAt(35) + r.charAt(36) + r.charAt(37) + r.charAt(38) + r.charAt(39) +  r.charAt(40) + r.charAt(41)
  
      for (var j = 0; j &lt; myaspects.length; j++) {
        if (aspect==myaspects[j]) {k1 = numval1[j]}
      }
  
      nplanet = r.charAt(45) + r.charAt(46) + r.charAt(47) + r.charAt(48) + r.charAt(49) + r.charAt(50) +     r.charAt(51)
  
      for (var j = 0; j &lt; myplanets1.length; j++) {
        if (nplanet==myplanets1[j]) {k2 = numval2[j]}
      }
  
      range = r.charAt(66) + r.charAt(67) + r.charAt(68) + r.charAt(69) + r.charAt(70) + r.charAt(71) +   r.charAt(72) +  r.charAt(73) + r.charAt(74) + r.charAt(75) + r.charAt(76) + r.charAt(77) + r.charAt(78) + r.charAt(79) + r.charAt(80)   + r.charAt(81) + r.charAt(82) + r.charAt(83) + r.charAt(84) + r.charAt(85)
  
      transits.innerHTML += "&lt;b&gt;" + range + "&lt;/b&gt;&lt;br&gt;" + myArray[k][k1][k2] + "&lt;br&gt;"
      transits.innerHTML += "&lt;br&gt;"
  
    }
  
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>TIA</p>