for (var i=list.length; i>=0; i--){
//do something....
}
I want to use a setInterval to make this process take 1 whole min no matter how many items are in the list. So if there are 10 items it would trigger every 6sec, 30items, every two seconds, etc.
Thanks for any help!
Something like this could be done:
JsFiddle Demo
I am not sure if this is what you’re looking for, but this will “iterate” through all items in the list, without using
forloop, in the given timeframe. The function will always “call itself” usingsetTimeout. The timeout is calculated in the beginning based on the number of items.This solution is much more “trustable” than
setInterval. The next timeout will be set when the previous action is already done, so it won’t stack up.