Domanda di colloquio di Affirm

How would you make this code more generic?