Pregunta de entrevista de Infosys

one javascript problem I have to solve