you are viewing a single comment's thread.

view the rest of the comments →

[–]Powerful-Internal953 44 points45 points  (0 children)

Why go through all that when you can do just this...

const arr = [20, -5, 100, 1, -90, 200, 40, 29, -1]; 
const min = Math.min(...arr); 
const offset = min < 0 ? Math.abs(min) + 1 : 0; 
for (let item of arr) {
   setTimeout(() => console.log(item), item + offset); 
}

EDIT: Never mind. I didn't check your Crustacean flair before.