Pregunta de entrevista de AKQA

Asked to refactor the given code.