The best description of how to build an electromagnet is:
Attach a wire to one end of a battery, wrap the wire around an iron or steel core, and attach the other end of the wire to the other end of the battery.
This method effectively creates a magnetic field when the current flows through the wire wrapped around the core, enhancing the magnetic properties of the iron or steel.