With the average student loan debt for the class of 2018 reaching $29,800, according to Student Loan Hero, it can be difficult for many young workers to set aside money for a distant retirement date when debt repayment is a top priority.
But according to Erin Lowry, author of "Broke Millennial Takes on Investing," the two goals don't have to conflict — you can invest for retirement and pay off your loans at the same time.
"It's really the question on most millennials' minds," Lowry tells CNBC Make It. "No one ever said they regretted paying off their debt, but at the same time if you take a 10-year hiatus on investing those are critical years that your money can be compounding and growing."
It's imperative to start investing early for a number of reasons. Perhaps the most important, as Lowry points out, is that the money you invest when you're younger has more time to earn compounded interest. Take this example, published in 1994 by USAA, which New York Times columnist and author Ron Lieber says changed his life.
The chart shows how your money would grow over time if you invest $250 a month at different ages, assuming an 8% rate of return.
If you start at age:
That said, it's hard to pay off debt, save and afford everyday expenses on most starting salaries. After you make the minimum payments on your debt each month, Lowry recommends contributing to your retirement account at least up to an employer match (if one is offered). Employer matches are part of your compensation — foregoing them means you're leaving money on the table.
More from Invest in You:
Wealth manager to millennials: These 3 steps will help you get rich
Budgets are 'pointless,' one financial coach says--here's what to do instead
'Shark Tank' star Robert Herjavec's first big splurge cost $6 million--and it wasn't a house
Vanguard recommends saving 12% to 15% of your income each year, including the match. But if it's just not possible, or if you aren't offered a match, then starting smaller works, too.
"If you can't do that right now, try 1%, try 2%, because if you're getting matched at 1% or 2%. you're automatically turning it into more money," Lowry says.
Beyond the match, you'll want to take into consideration the interest rate on your loans. Compare it to the "expected" return on investments — the historic return for the S&P 500 is around 6% — and the length of time you have until retirement.
Lowry says the investing experts she interviewed for her book all came back with the same number: 5%.
"If the interest rate on your student loans is 5% or higher then it probably makes more sense for you to focus on paying down those student loans," she says. But if your rate is below that, then investing now and slowing paying off your loans might be a better plan. Of course, consider your own debt tolerance, too. You might be more comfortable putting extra money toward your loans than into your 401(k).
Like this story? Like CNBC Make It on Facebook.
Disclosure: NBCUniversal and Comcast Ventures are investors in Acorns.