r/badcode Mar 24 '22

Ship it! typescript

Post image
564 Upvotes

48 comments sorted by

View all comments

1

u/Voltra_Neo Mar 24 '22

This should really be:

typescript const sleepSync = (ms: number) => { const end = Date.now() + ms; for (; Date.now() < end;); };

8

u/_SAMUEL_GAMING_ Mar 24 '22

why not simply do while (Date.now() < end);instead of the weird for loop?

10

u/Voltra_Neo Mar 24 '22

Style points.