Even with all the volatility and the flirting with bear-market territory, the S&P 500 index is well in the green this year, up about 8% since early January. Some stocks haven't been so lucky, though.

Novo Nordisk (NVO 1.34%) and Regeneron Pharmaceuticals (REGN -0.25%), two leading drugmakers, have underperformed for most of the year, significantly lagging the broader market. These healthcare giants are facing some headwinds, but does that mean investors should steer clear of them?

Let's find out.

Doctor talking to patient.

Image source: Getty Images.

1. Novo Nordisk

Novo Nordisk has been facing several challenges that predate this year. It encountered a clinical setback for what Wall Street thought was a promising weight management candidate. Furthermore, the company's financial results, although strong when compared to its similarly sized peers, were not seen as sufficient because it's held to a higher standard.

These challenges have led to a terrible performance this year. Novo Nordisk's shares are down by 18% year to date, significantly lagging the S&P 500. However, the stock might be a steal right now.

The company has made several moves that should allow it to recover. Novo Nordisk's pipeline, especially in diabetes and weight management, remains one of the strongest in the industry. It recently initiated a phase 3 study for amycretin -- its next-generation GLP-1 medicine -- in both subcutaneous and oral formulations.

It requested regulatory approval in the U.S. for an oral version of semaglutide, its well-known medicine marketed as Wegovy for weight loss and as Ozempic for diabetes management. Novo Nordisk has also penned several licensing deals that have expanded its pipeline in weight management. The company should launch at least one new medicine in its core therapeutic area within the next few years.

Financial results should remain strong as Ozempic and Wegovy continue driving solid revenue growth. Considering the stock's sell-off over the past years, shares now look more than reasonably valued relative to Novo Nordisk's growth potential. Their forward price-to-earnings ratio of 16.9 is in line with the healthcare industry's average of 16.5 as of this writing.

However, Novo Nordisk typically grows its revenue and earnings faster than its peers. That makes its stock attractive at current levels, based on its growth potential.

2. Regeneron Pharmaceuticals

Regeneron is facing biosimilar competition for Eylea, a medicine for wet age-related macular degeneration that was once one of its biggest growth drivers. Sales of the medicine have dropped, dragging total revenue down with them. That's the most important reason why Regeneron's shares are down by 19% since the year started.

However, the stock is still attractive. The biotech might go through a period of its top line declining, but it can still recover. Here are three reasons why.

First, the company's newer, higher-dose (HD) formulation of Eylea is taking market share away from its previous version. HD Eylea is performing well and will grow even faster once it earns some label expansions.

Second, Regeneron has a deep pipeline that's expected to yield new brand approvals. Earlier this month, it earned the green light for Lynozyfic, a cancer medicine, in the U.S. One of its more promising candidates is a gene therapy for one type of genetic deafness, which is showing incredible potential in clinical trials. Regeneron should move beyond Eylea thanks to newer approvals.

Third, the company's most important product, Dupixent, an eczema treatment, is performing exceptionally well. The medicine has earned important label expansions in recent years, including in treating chronic obstructive pulmonary disease (COPD) and a rare skin condition called bullous pemphigoid. Dupixent will maintain its upward growth trajectory for a while.

Here's one more reason to invest in Regeneron: The company is committed to returning capital to shareholders. It recently initiated a dividend and has a robust share-buyback program in place.

The stock might be moving in the wrong direction right now, but those willing to hold onto it for five years or more could see superior returns over the long run.