AKQA Interview Question

Asked to refactor the given code.