Nielsen interview question

Machine coding question for React