Cognizant interview question

Javascript code