Here’s a free tutorial from my course On writing JavaScript well.
Lengthy functions are a pain to maintain. Sometimes cleaning them up is as simple as finding the line between executing a command and querying for information. Check out how this beast of a function was cleanly sliced into two parts: