There's value in finding a beleaguered stock, in which investors have lost faith, that you believe can mount a comeback. Of course, in most cases, when a company has sunk to share-price lows, it's for a good reason. Conversely, when share prices have shot up, it's time to ask whether upside potential remains.

Retailers Wal-Mart (NYSE:WMT) and J.C. Penney (NYSE:JCP) exemplify these two scenarios. A decision to buy the former would depend on whether you believe the company still has upside. When you weigh buying the latter, you have to determine if it even has a future. Wal-Mart has shown that it's going to remain a strong player in an omnichannel world. J.C. Penney has in no way proven that, and there is uncertainty about its long-term viability as a going concern.

JCP Chart

Data by YCharts.

The case for J.C. Penney

J.C. Penney has made progress on its turnaround strategy: The company has added appliances successfully to more than half of its stores. It has also focused on making its stores destinations by revamping its salons and focusing on its store-within-a-store Sephora locations. In addition, the retailer has also revamped some of its merchandise to better reflect consumer demand.

In theory, these changes should work -- but the results have been mixed. Same-store sales did rise 1.7% year over year in Q3, but total sales fell 1.8%, from $2.86 million to $2.81 million. The chain also saw its net loss increase to $128 million from $67 million a year ago.

"During the third quarter, we took aggressive actions to clear slow-moving inventory, primarily allowing for an improved apparel assortment heading into the holiday season," explained CEO Marvin Ellison in the earnings release. "While these actions had a negative short-term impact on profitability in the third quarter, we firmly believe it was the right decision for the company as we transition into the fourth quarter and fiscal 2018."

J.C. Penney has made a lot of the right moves, but it has not proven that those moves will pay off. Its stock offers great value if you're confident that a turnaround will happen, but there's a strong risk of eventual bankruptcy.

WMT Chart

Data by YCharts.

The case for Wal-Mart

As you can see, Wal-Mart's share price is going in the opposite direction to J.C. Penney's. Wal-Mart has succeeded in recent quarters in moving its company to more of an omnichannel model. It has invested heavily in integrating its digital operations with its stores, and both consumers and investors seem to like what's happening.

In its Q3, the retailer saw total revenue jump by 4.2%, and U.S. comparable-store traffic rose by 2.7% while comparable-store traffic was up 1.5%. In addition, net digital sales rose by 50%.

"We have momentum, and it's encouraging to see customers responding to our store and e-commerce initiatives," said CEO Doug McMillon in the earnings release. "We are leveraging our unique assets to save customers time and money and serve them in ways that are easy, fast, friendly and fun."

The exterior of a JCPenney.

J.C. Penney still has tremendous risks as it struggles to survive. Image source: Getty Images.

Which is a better buy?

While I remain optimistic that J.C. Penney has a future, I believe it has a better chance of going out of business than Wal-Mart does of failing in its omnichannel conversion efforts. True, J.C. Penney has more upside, but that's only because it has fallen so far.

Wal-Mart is a better buy because it offers a better balance of upside and risk. It may not have the short-term potential to post massive gains that J.C. Penney would if it can prove long-term viability, but it's clearly a stable company moving in the right direction.

Still, if you trust that J.C. Penney will turn the corner, I suggest making a small investment. For example, buy Wal-Mart, but maybe take 10% of what you plan to invest and bet on Ellison being able to get his company back to a viable place.

Wal-Mart has proven that the needle is pointing up, but exactly how much upside it has remains to be seen. J.C. Penney shares could double, triple, or even more, but only if the company clears some very big hurdles.

Daniel B. Kline has no position in any of the stocks mentioned. The Motley Fool has no position in any of the stocks mentioned. The Motley Fool has a disclosure policy.