Solving a practical intermediate react interview challenge