Hola Interview Question

Refactor 25 lines function into smaller one