In early June, the S&P 500 closed 20% from its most recent low, which, one could argue technically marks the start of a new bull market. No one knows how long it will last, but every investor wants to profit from it. One way to do so is to target companies that don't seem to be doing too well but still have solid long-term prospects.

However, it's also vital to avoid struggling stocks that seem to be going nowhere. Let's look at two companies whose financial results haven't been strong in recent quarters: Snap (SNAP 27.63%) and Chegg (CHGG 3.20%). The former still looks like a buy despite its unimpressive quarterly updates, while the latter is less attractive. 

The struggling stock to buy: Snap

Snap is a social media specialist that has encountered some of the same issues as its competitors. The company makes most of its money from ads, a tricky industry to be in right now. But while other social media companies, such as Meta Platforms, seem to be rebounding, Snap is still struggling to grow its revenue. In the second quarter, the company's top line declined by 4% year over year to $1.1 billion.

That's a bit puzzling, considering Snap's average daily users (DAUs) have been on an upward trend. In the period, this number increased 14% year over year to 397 million. But the company's average revenue per user declined by 16% year over year to $2.69.

So despite more users, Snap is squeezing less out of them. Further, the company remains unprofitable, although its net loss in the second quarter of $377.3 million improved by 11% year over year.

There are plenty of redeeming qualities for Snap. The fact that its ecosystem continues to expand is a good sign, and the company is also seeking various new ways to make money. Its subscription service Snapchat+ now boasts more than 4 million users. This initiative was first announced only about a year ago. Elsewhere, Snap's AI-powered chatbot, My AI, has seen tremendous success since its launch in February.

Snap reports that more than 150 million users have sent more than 10 billion messages through My AI. These are great signs that engagement is improving on Snap's platform, and as long as its user base keeps growing, the company can find more ways to monetize it and help it bounce back. Snap's position as one of the leading social media companies with a vast, expanding ecosystem and multiple potential growth avenues that also include augmented reality make it an intriguing stock to buy on the dip.

The struggling stock to avoid: Chegg

Chegg is an online learning platform that risks becoming obsolete due to the rise of generative AI applications like ChatGPT. The now-infamous chatbot can answer questions -- sometimes very complex ones -- on a range of topics of interest to students. ChatGPT can also assist in writing essays, which makes it a highly versatile tool for students, one that could potentially replace Chegg's subscription service.

That's why the company's stock has underperformed this year. Chegg is also suffering from poor financial results, although that isn't the result of the threat from AI. In the second quarter, Chegg's revenue of $182.9 million decreased 6% year over year. It registered 4.8 million subscribers, 9% lower than the prior-year quarter. Chegg is facing challenging comparisons to the earlier pandemic days, when an abnormal number of students signed up for the services it offered.

However, there was progress on the bottom line. Chegg's net income of $24.6 million more than tripled compared to the second quarter of 2022. Most of the company's net income in the period was due to a gain on an early retirement of debt recorded in Chegg's "other income."

Overall, Chegg's results continue to suffer from tough comparisons, but they weren't all that bad. Still, the AI threat looms, although management has made moves to get ahead of it.

Earlier this year, it announced it was working on an AI-powered study helper called CheggMate. It launched a beta version of this program in May and claims that feedback has been positive. Further, according to various surveys, students see ChatGPT and services like Chegg complementing one another, as opposed to working against one another.

Does that mean investors shouldn't worry about Chegg's future? In my view, it is still far too early to declare that the company will thrive in this new world of AI. We need more tangible results before making that pronouncement. And unless Chegg can find a way to fend off this threat, its future looks uncertain. That's why investors should avoid Chegg stock, at least for now.