r/badcode • • Jan 03 '21

js setTimeoutception

Post image
719 Upvotes

35 comments sorted by

View all comments

23

u/[deleted] Jan 03 '21

If only there was a way to... loop

2

u/beckettobrien Jan 03 '21

Yeah, I probably could have found a better way to do it looking back so it could be, uh, more readable. It isn’t quite straightforward enough to use a loop because I also have each timeout call a function with a different argument each time, but it probably would be easier to have an array of objects that contain the function to run and the timeout so I could loop over it and have less of a headache, but it’s not for anything important so I don’t care :)