capacitor on motor

Hi, I took apart a RC car, the motor has a ceramic capacitor between the positive and negative terminal with a number 104. What is the purpose of this capacitor?

Noise suppression (helps anyway). The 104 is read like a resistor color code - it is 10 followed by 4 zeros pf (100,000 pf or .1 ufd)

The motor produces sparks as it rotates.
These sparks play havoc with near by electronics.
The capacitor helps reduce or may eliminate the sparks (noise).
.

It reduces the EMI from the motor wiring due to the high frequency noise the sparks generate - you'd
need a larger capacitor to snub out the sparks I think, but that's not compatible with driving a motor
from a driver with PWM, since you don't want to drive a highly capacitive load. The capacitor
value is a compromize.

MarkT:
you'd need a larger capacitor to snub out the sparks I think, but that's not compatible with driving a motor from a driver with PWM, since you don't want to drive a highly capacitive load.

Actually, it is the same situation as the PWM!

The capacitor enhances the sparks if anything. It is there purely to confine the electrical noise within the confines of the motor casing - which is why there are generally two capacitors, one on each brush, soldered directly to the casing.