The answer to 'how to fix junction box' is to first turn off the power to the junction box at the circuit breaker. Then, remove the cover and inspect the connections inside. Tighten any loose wires or terminals, and check for any signs of damage or wear. If everything looks good, replace the cover and turn the power back on.
If you notice any issues like burned wires, loose connections, or water damage, it's best to call a licensed electrician to properly diagnose and repair the junction box. Attempting DIY electrical work can be dangerous if you're not trained, so it's important to know your limits and when to bring in a professional.