Overcoming the spirit of discouragement is a part to success. You can not control everything in your life but you can control your reaction to everything in your life.
Controlling your reactions to unpleasant situations depends on how you perceive life.
Failure in a good course is not a failure until you get discouraged.
Don't be discouraged no matter the circumstances. Believe in yourself and you will win in the end.
Sometimes if you don't taste the bitter you will not know the price of the sweet.
Life is a test.
See quote
I should never get discouraged, whatever difficulties should surround me, if I was sunk in the lowest pit of Nova Scotia and all the Rocky Mountains piled on top of me, I ought not to be discouraged but hang on, exercise faith and keep up good courage and I should come out on the top of the heap.
Joseph Smith Jr. (Quoted in Memoirs of George A. Smith)