They are positively or negatively charged based on their electrical configuration of electrons* For example an electronic configuration of 2,8,3 would have a negative charge if +3 since it needs to lose 3 electrons to gain the electrical configuration of a noble gas 2,8,1 would have a charge of +1 for the same reason 2,8,6 would be -2 since it is easier to gain 2 electrons that lose 6 electrons