r/badcode • • Apr 13 '22

js Found this monstrosity while refactoring some of my old code

Post image
205 Upvotes

85 comments sorted by

View all comments

Show parent comment

3

u/Astrogat Apr 13 '22

While I agree that the formatting could be better on the last one, it's still simple to go command by command. He maps it all to utc dates, then he creates a set and he converts to date. It's like 3 commands, all of them quite basic.

4

u/Thebluecane Apr 13 '22

He just needs a comment on the New code is all. Once you start doing multiple things on all in one go just leave comment and format it properly

2

u/Astrogat Apr 13 '22

Well, hopefully the whole thing is a function with a sensible name, in which case I don't see the need for a comment. But yeah, either making a variable for the date list (as the nesting with the set creation require some thought) or splitting it in a few lines should be enough.