Diet is important part of maintaining good oral health.
Plaque is a thin film of bacteria that builds up on your teeth, which over time if not removed can causes cavities. The more food and or drinks you have that contain high sugar content the higher risks are of plaque developing and leading to cavities. Protect your teeth by having a well balance diet with low sugar.
Not to say you can not have those sugary sweets once in a while but try to limit them and remember to brush twice a day and floss daily in order to help reduce plaque build up on your teeth.