Pregunta de entrevista de Attentive

Asked to write a function