Stripe interview question

How would I optimize my code