Consumer electronics retailer Best Buy (BBY -0.81%) is proving that competing with Amazon isn't a fool's errand. The company has spent the past five years cutting costs, investing in e-commerce, and making its prices more competitive. These moves have led to an impressive comeback.

There are plenty of reasons to love Best Buy stock. The company reported 9% comparable-sales growth during the fourth quarter, a blowout result. It expects adjusted earnings per share to grow to as much as $5.75 in fiscal 2021, putting the price-to-earnings ratio based on that target at roughly 13.

But the real reason to love the stock is a rock-solid balance sheet that gives the company the flexibility it needs to thrive well into the future.

The Best Buy logo on the front of a store.

Image source: Best Buy.

Building a fortress

Current Best Buy CEO Hubert Joly took the reins in August 2012, which marked the start of the company's multiyear turnaround. Prior to Joly's ascension, Best Buy's balance sheet was nothing to write home about. At the beginning of March 2012, Best Buy had $1.2 billion of cash and $2.2 billion of debt.

Debt can act as an anchor for retailers, preventing them from making necessary investments to keep up with changing consumer behavior. Best Buy has made significant investments in its e-commerce business over the past five years, including implementing ship-from-store and redesigning its website. The result has been consistent double-digit online sales growth.

Cost cuts have paid for these investments, but Best Buy simultaneously raised cash by selling off some of its international businesses. The company announced the sale of its European business in 2013, and the sale of its Chinese business in late 2014. These segments were distractions, and divesting them allowed the company to focus on its core North American operation.

These moves, along with consistent free cash flow generation over the past few years, have bolstered Best Buy's balance sheet by billions of dollars. At the end of fiscal 2018, Best Buy had $3.1 billion of cash and just $1.36 billion of debt. That cash balance would be even higher, but Best Buy initiated a two-year $3 billion share buyback program a year ago, and it's been boosting its dividend at a double-digit rate.

A strong balance sheet gives a retailer room for error, as well as the ability to weather nearly any storm. A debt-ridden retailer entering a recession may not survive, eaten alive instead by its past mistakes. But a retailer with plenty of available cash and little debt can ride out a downturn in demand and have the resources to take advantage of opportunities.

A strong balance sheet also allows Best Buy to be aggressive when it comes to share buybacks and dividends. It spent $2 billion in fiscal 2018 buying back its own shares, on top of about $400 million in dividends. Best Buy boosted its dividend by 32% earlier this month, and it added an additional $500 million to its two-year share buyback authorization. All of this was made possible by the company's fortress of a balance sheet.

What's next for Best Buy?

Best Buy's plan for the next few years revolves around further cost cuts and investments in expanding the scope of what it sells. Smart-home devices will be a major focus, with Best Buy planning to add 1,500 dedicated smart-home employees to its stores. Best Buy wants to not only sell gadgets, but also services. It recently expanded its in-home advisor program, and it launched Total Tech Support, which provides ongoing support regardless of where the customer bought the product.

With shares of Best Buy up more than 500% since bottoming out in late 2012 and trading for 16.5 times fiscal 2018 adjusted earnings, the stock is not a clear-cut bargain. But I have little doubt that the company will continue to succeed in the years ahead, thanks in part to its strong financial foundation.