title: Executing AJAX based on times stored in two different arrays?
body: <p>This is one of those situations that its a bit tricky to explain the issue but I will try my best to explain it so I can get some help here.</p>
  <p>basically I have a project that I need to allow the users to login/logout even if they have no internet connections.</p>
  <p>Every time they login/logout while offline, I store 2 arrays and push to it so I can log them in/out accordingly based on the time they logged in/out.</p>
  <p><strong>The arrays look like this:</strong></p>
  <pre><code>var logins = [{&quot;id&quot;:1,&quot;dateAdded&quot;:&quot;2021-10-29T18:27:35.754Z&quot;}, {&quot;id&quot;:2,&quot;dateAdded&quot;:&quot;2021-10-29T18:28:35.754Z&quot;}, {&quot;id&quot;:3,&quot;dateAdded&quot;:&quot;2021-10-30T18:28:35.754Z&quot;}];
  
  var logouts = [{&quot;id&quot;:1,&quot;dateAdded&quot;:&quot;2021-10-29T18:27:50.754Z&quot;}, {&quot;id&quot;:2,&quot;dateAdded&quot;:&quot;2021-10-29T19:28:35.754Z&quot;}];
  </code></pre>
  <p>To explain the arrays, the id is the <code>id</code> of the account that they <em>logged in/out</em>. the <code>dateAdded</code> is basically the time date that they <em>logged in/out</em>.</p>
  <p>Now, the issue: When I run my AJAX code in the below code/fashion, it works fine BUT everything gets executed at the same time which sort of floods the login/logout system and therefore it either won't login or logout of the account(s).</p>
  <pre><code>for(let dataSings of logins){
  
  //do my ajax stuff here
  
  }
  
  for(let dataSingo of logouts){
  
  //do my ajax stuff here
  
  }
  </code></pre>
  <p>What I need to do is to come up with a good solution to look into these Arrays, and then log them in and then look into the arrays for the logout with the same id and them log them out again and so on and so forth...</p>
  <p>and all of these has be based on the time that its stored in the Array (<code>dateAdded)</code>.</p>
  <p>I hope I explain this well enough to get some lights shed on it.</p>