Pergunta de entrevista da empresa Stripe

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