I don’t agree with using credit cards as the source of fund. Because,
1. It’s hard to get $40K in one or two 0% credit cards.
2. Such big balance would drag down your credit score and therefore negatively influence the mortgage rate you can get.
3. You have to find the next available 0 cards in a year again and again.
If she loses her job in 5 years (before pays back the 401K loan), she can chose to take the rest of the loan out as an early distribution and pay income tax of that portion. Without a job, I guess her tax brake would be lower than now.