Pregunta de entrevista de Barley

Word problem to be solved using JavaScript