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 ensures that the wire creates a loop around the core, generating a magnetic field when electric current flows through it.