The answer to 'how to replace GFCI outlet' is to replace the old GFCI outlet with a new one. GFCI (ground fault circuit interrupter) outlets are important safety devices that protect against electric shock hazards. Replacing a GFCI outlet is a relatively simple DIY task, but it's important to follow safety precautions and turn off power to the circuit before starting.
First, turn off power to the circuit at the circuit breaker. Then, remove the old GFCI outlet by unscrewing it from the electrical box and disconnecting the wires. Install the new GFCI outlet by connecting the wires (hot, neutral, and ground) to the corresponding terminals. Secure the new GFCI in the electrical box and restore power to test it.