Pergunta de entrevista da empresa Infosys

one javascript problem I have to solve