ugh I'm so sorry, your friend shouldn't have said that at all, that's not helpful

your friend should be supportive and encouraging, even if they personally dont agree with you, that doesnt matter, the aim is to make you feel better not make you feel worse by inflicting their negativity onto you

probably one of those scenarios where the person didn't think before they spoke.
I know its hard cause you value your friend's opinion, but please on this occasion ignore it. Someone's opinion doesn't dictate reality, it's triggering as hell, I know that first-hand from people telling me hopeless stuff too, but it's just their mindset/opinion, it doesn't determine actual reality.
I hope you can forget what your friend said, and get that little bit of hope back