title: Cannot call method 'split' of undefined - Called From Function
body: <p>I have a JS function that is called on load that spilts some variables, this all works well, but when I call the function from another function, I get this error <code>Cannot call method 'split' of undefined</code>:</p>
  
  <pre><code>function loadInAttachmentsIntoSquads(){
      // eg: 5000,5000,5000,5000 &gt; [5000][5000][5000]
      myAttachmentArray = currentAttachments.split(',');
  
      //eg: [5000][5000][5000] &gt; [5][0][0][0]
      //myAttachmentForWeapon = myAttachmentArray[mySquadsIndex].split('');
  
      setupWeaponAttachments();
  }
  
  
  function setupWeaponAttachments(){
  
      myAttachmentForWeapon = myAttachmentArray[mySquadsIndex].split('');
  
      //if(mySquadsIndex == 0){
          if(myAttachmentForWeapon[1] == 1){ // if silencer is on? //first digit is always 5
              weaponAttachments.silencer = true;
          }
          else{
              weaponAttachments.silencer = false;
          }
          if(myAttachmentForWeapon[2] == 1){ // if silencer is on? //first digit is always 5
              weaponAttachments.grip = true;
          }
          else{
              weaponAttachments.grip = false;
          }
          if(myAttachmentForWeapon[3] == 1){ // if silencer is on? //first digit is always 5
              weaponAttachments.redDot = true;
          }
          else{
              weaponAttachments.redDot = false;
          }
  
      // -- applies visuals -- \\
      applyWeaponAttachments();
  }
  </code></pre>
  
  <p>If I call <code>setupWeaponAttachments()</code> from another function, I get that error ... why?</p>