Question d’entretien chez Infosys

one javascript problem I have to solve