Pregunta de entrevista de Hola

Refactor 25 lines function into smaller one