Publicis Sapient Interview Question

Writing a code for some random function .