Sollicitatievraag bij Affirm

How would you make this code more generic?