Pergunta de entrevista da empresa Semrush

How would you refactor this big function?