why are ions attracted to electrodes?
This is because positive calcium ions are attracted to the negative electrode (cathode), where they gain electrons to form calcium atoms. At the same time, negative chloride ions are attracted to the positive electrode (anode).