The Beginner’s Guide to Investing

Coke vs Pepsi: Here's which stock would have made you richer if you invested $1,000 10 years ago

Investing in these stocks would have made you rich by now—here are other...

Coca-Cola, the parent company of popular soft drink Coke, and PepsiCo, which owns longtime rival Pepsi, are in an ongoing battle to win over more of the world's soda drinkers.

Both have their share of celebrity fans. Investing legend Warren Buffett calls himself a "Coke loyalist," while Pepsi has, over the years, received Super Bowl endorsements from A-listers like Steve Carell, Cardi B, Beyoncé and Madonna. (This year's game, in which Americans are expected to spend a whopping $15.3 billion on food, drinks, decorations and related items, airs February 3.)

Both brands have proven, over the years, to be extremely successful, and both landed a spot on the Forbes list of the world's most valuable brands in 2018.

So, which would have made you richer if you invested 10 years ago?

Coca-Cola but only barely. In fact, it's basically a tie.

CNBC: Coca-Cola stock as of Jan. 30, 2019

According to CNBC calculations, a $1,000 investment in Coca-Cola in 2009 would be worth more than $2,700 as Jan. 30, 2019. If you put $1,000 in PepsiCo at the same time, your investment would be worth more than $2,600. The difference between the two comes to only about $100.

Although the companies' stock prices have been largely steady over the years, any individual stock can over- or underperform, and past returns do not predict future results.

Ivan Feinseth of financial firm Tigress Financial Partners sees a big problem facing Pepsi and the traditional soda market overall: "The biggest problem that Pepsi" and similar companies face, he said on CNBC's "Squawk Box," "is that there is no growth in carbonated soda.

"The company has to continue to develop or acquire other alternatives: sparking water, flavored seltzers, flavored teas, sports drinks, recovery drinks. That's where the growth is, in the niche beverage markets."

Both Coca-Cola and Pepsi-Co do offer products besides sodas, and both continue to make acquisitions to diversify their portfolios of products. Pepsi-Co, which owns the popular snack brands Cheetos, Doritos and Lays, as well as beverage brands Gatorade and Lipton, announced plans to buy at-home carbonated-drink maker SodaStream.

Coca-Cola made six new acquisitions in 2018, among them coffee chain Costa Coffee, though chief executive officer James Quincey said on CNBC's "Squawk on the Street" that investors shouldn't expect the company to keep up the pace in 2019. Instead, he says, the company will "absorb" the investments it made last year.

At the 49th World Economic Forum in Davos, Quincey said, "I think we are in the phase of 2019 where we are likely to see a little less growth or a little less tailwind. It is going to be a slightly tougher year in macroeconomic terms and we need to work our way through it."

CNBC: PepsiCo stock as of Jan. 30, 2019

Other investors suggest that worries about tougher years ahead make these companies good buys. "Mad Money" host Jim Cramer said in early January that investors should opt for stocks like Coca-Cola and Pepsi-Co that could do well even during a potential recession or in case of a stock market crash.

"You buy the stocks of companies that do well in a recession — even though I don't think we're going into one — that are also bolstered by lower raw costs," Cramer said. He specifically highlighted Coca-Cola and PepsiCo: "They're the safety stocks. That's what's worth owning."

If you're looking to get into investing for the first time, expert investors like Buffett, Mark Cuban and Tony Robbins suggest you start with index funds, which hold every stock in an index, offer low turnover rates, attendant fees and tax bills. They also fluctuate with the market to eliminate the risk of picking individual stocks.

Like this story? Subscribe to CNBC Make It on YouTube!

Don't miss: Disney vs Netflix: Here's which stock would have made you richer if you invested $1,000 10 years ago

Here's how young people should invest their first $10,000