How an electromagnet works:
The current runs through the coil, converting it into a magnetic field.
There are 3 factors that affect the strength of the magnetic field:
1. The amount of current
2. Number of turns of the copper wire
3. The core material, soft iron is the best