Infosys interview question

Coding question in react .js