A new study has found that those who eat peas, broccoli and spinach are less likely to suffer from dementia.