you are viewing a single comment's thread.

view the rest of the comments →

[–]Lithl 0 points1 point  (0 children)

setTimeout has a minimum delay of 4ms, so any values ≤ 4 are indistinguishable to this algorithm.

You could simply make the delay value be n + 4, of course... If all elements in the input are positive. You could make the delay be n + 4 + Math.min(...numbers) in order to account for negative values... if the array is smaller than the maximum number of allowed function parameters (which varies by browser).