If investor plans to hold a bond to maturity, the change in credit spreads throughout the holding period is effectively zero

I just read this somewhere, and I’m not able to understand the reasoning behind it. Could someone help please ? Thanks.

If you hold a bond, and the interest rate goes up and down and all over the place… But you hold it to maturity and collect your $1000, what happen to the YTM of the bond? Did you still get $1000?

That answer will be the similar to your question.

That helps. Thanks.