I am trying to loop some values, which are milliseconds. i need to run some code every xxxx second, depending on the value that he gets from the loop, but i cant get it to work, well it works but it doesn't run on time.
The code is included a reset button(the code is from a plugin, but i had to modify it)
//plugin options
  step:[
      {
          time: 6000,
          // more stuff here 
          // but we dont need 
          // it in this example
      },
      {
          time: 3000,
          // more stuff here 
          // but we dont need 
          // it in this example
      },
      {
          time: 12000,
          // more stuff here 
          // but we dont need 
          // it in this example
      }
  ]
// the loop
  var timeouts = [];
  $.each(options.step, function(i, value){
      var time =  value.time;                                                       
      timeouts.push(setTimeout(function(){
          alert('some action');
      },time*i));
  });
// reset button
  $('.stop').click(function(){
      $.each(timeouts, function (_, id) {
          clearTimeout(id);
      });
      timeouts = [];
  })
 
     
     
    