Stripe Interview Question

Multi part question on strings, array manipulation which got complex with every subsequent part