title: How can I store a value in javascript and then recall it later depending on what "part" of the array was clicked?
body: <pre><code>HTML
  
  &lt;!--ACU Cards--&gt;
  &lt;div class=&quot;mainSplitContainer factionPadding&quot;&gt;
    &lt;div class=&quot;splitContainer column3&quot;&gt;
      &lt;div class=&quot;splitItem scrollFade animationLeft acuCard&quot; id=&quot;acuUEF&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;splitContainer column9 acuAbsolute&quot;&gt;
      &lt;div class=&quot;splitItem factionAbsolute acuAbsoluteActive&quot;&gt;
        &lt;div class=&quot;splitImage scrollFade&quot;&gt;&lt;img src=&quot;../img/uef.jpg&quot; alt=&quot;&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;splitContainer column3 acuCard&quot;&gt;
      &lt;div class=&quot;splitItem&quot;&gt;
        &lt;div class=&quot;splitImage scrollFade animationLeft&quot;&gt;&lt;img src=&quot;../img/acucybran.jpg&quot; alt=&quot;&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;splitContainer column9 acuAbsolute&quot;&gt;
      &lt;div class=&quot;splitItem factionAbsolute&quot;&gt;
        &lt;div class=&quot;splitImage scrollFade&quot;&gt;&lt;img src=&quot;../img/cybran.jpg&quot; alt=&quot;&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;splitContainer column3 acuCard&quot;&gt;
      &lt;div class=&quot;splitItem&quot;&gt;
        &lt;div class=&quot;splitImage scrollFade animationRigth&quot;&gt;&lt;img src=&quot;../img/acuaeon.jpg&quot; alt=&quot;&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;splitContainer column3 acuCard&quot;&gt;
      &lt;div class=&quot;splitItem&quot;&gt;
        &lt;div class=&quot;splitImage scrollFade animationRigth&quot;&gt;&lt;img src=&quot;../img/acuseraphim.jpg&quot; alt=&quot;&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  
  
  
  JS
  
  
  let acuCard = document.getElementsByClassName(&quot;acuCard&quot;);
  let factionAbsolute = document.getElementsByClassName(&quot;factionAbsolute&quot;);
  
  
  for (let i = 0; i &lt; acuCard.length; i++) {
    acuCard[i].addEventListener(&quot;click&quot;, () =&gt; {
      factionAbsolute[i].classList.toggle(&quot;acuAbsoluteActive&quot;);
      
      let storeVariable = 0;
      storeVariable.push(i);
  
  </code></pre>
  <p>So I have this function that depending on which acuCard is clicked, it toggles a class for factionAbsolute, I want to store the value of which card was used. So if the second card (1) was clicked, I want to be able to store that in a variable. This is because I want to make it have a different behavior if the same card is clicked again, like an if statement like</p>
  <p>if i == storedVariable... (storedVariable being the last acuCard that was clicked)</p>
  <p>how could I achieve this? I think something with push or shift but I cant make it an array or it will always have the value 0</p>