Sollicitatievraag bij Semrush

How would you refactor this big function?