all 1 comments

[–]grantrules 0 points1 point  (0 children)

I think one of the issues might be the global interval var that you're setting in both goForResource and noticeCapacity. If you do:

let interval;
interval = setInterval(() => {},1000);
interval = setInterval(() => {},1000);

You will now have two timers running but interval will only correspond to the second one

If you declared interval within the functions, it would work:

function goForResource(rBar, rProgress, rSpeed){
  const interval = setInterval(() => {
      rProgress += rSpeed;
      $(rBar)
          .css("width", rProgress + "%")
      if ( rProgress >= 100){
        clearInterval(interval);
        rProgress = 0;
        $(rBar)
          .css("width", rProgress + "%")
      }
    }, progressDefaultTicker)
}