Domanda di colloquio di Infosys

one javascript problem I have to solve