The last three years have seen a pandemic-driven market crash turn into a soaring (nearly bull) market, only for rising inflation and weak consumer spending to send stocks back down again. There's a lot of uncertainty about what happens next for the economy and the stock market, but investors with a long time horizon can still put money to work.

The most important factor in building wealth is persistent saving and investing regardless of the broader economy. Regularly adding money to a group of businesses that consistently grow their sales and profits is all it takes.

Chewy (CHWY 2.99%) and Ulta Beauty (ULTA -0.40%) have already demonstrated above-average growth in recent years, but the market could be undervaluing their future growth over near-term weakness in the economy. Investors can now buy shares of these two growth stocks at attractive valuations that could set up a long run of explosive returns down the road.

1. Chewy

Share prices of Chewy sank to new lows recently and are currently trading at a fraction of the previous high of $120 a few years ago. Wall Street is growing nervous over a weak consumer spending environment and rising interest rates, but Chewy is not a throwaway business.

The online pet care supplier has a loyal customer base, with 75% of sales coming from its autoship program. Net sales have more than doubled over the last three years, although investors are concerned about slowing growth in the near term as consumers tighten their household budgets. Wall Street analysts expect Chewy to report full-year sales growth of 11% for fiscal 2024 ending in January.

Most importantly, Chewy is a profitable business with a net profit of $41 million on $5.5 billion in sales in the first half of the year. Profits would be even higher, but Chewy is currently expanding its fulfillment center capacity and technology for future growth.

Chewy is also rock solid financially. It held $905 million in cash and marketable securities on its balance sheet at the end of July, with just a small amount of long-term liabilities. This well-financed, profitable business with a loyal customer base appears undervalued by the market.

The stock's price-to-sales ratio of 0.69 is a screaming bargain. The shares might hit new lows before heading higher, but investors should have confidence in buying and holding shares for the long term.

2. Ulta Beauty

Ulta Beauty is another promising growth stock that fell out of favor on Wall Street. The cosmetics market recovered quickly from the pandemic, which has been a boon for this leading retailer of beauty products. After hitting a high of about $550 earlier this year, the stock is down about 30%, but that is an opportunity to get more value for your investment.

Ulta operates more than 1,250 stores across the U.S. Its relationship with leading brands and a growing customer loyalty program delivered above-average growth and returns to shareholders.

However, soft consumer spending is starting to catch up with the company, so investors will have to be patient with this one. In the quarter ending in July, comparable sales slowed to 8%, well off the 14% it reported last year in the same quarter. Earnings growth averaged 24% annually over the last 10 years, but based on Wall Street estimates, Ulta may report a single-digit increase this year.

The stock might stay down for a while, but its valuation is attractive. Its forward price-to-earnings ratio is currently 15, which is a bargain for a company with a record of double-digit growth in sales and profits.

Moreover, Ulta Beauty is still a small player in the $104 billion beauty market. Its trailing revenue of $10.7 billion allows for more growth domestically, not to mention international opportunities down the road.

There are a lot of concerns about the health of the economy, especially with household debt on the rise. Focusing on profitable market leaders trading at low multiples of annual sales or earnings should pay off over the long term.