Infosys interview question

one javascript problem I have to solve