KPMG interview question

common question in react and javascript