Infosys Interview Question

one javascript problem I have to solve