Answer:
There are many advantages of electromagnets over bar magnets but one of the primary advantages is that magnetic field can be turned on and off and if multiple electromagnets are used then the power of the magnetic field in an electromagnet can also be controlled.
Like advantages, there are multiple disadvantages of electromagnet but one of the major disadvantages is that it requires current to operate so it takes a lot of energy and heats up very fast