The more thoughful articles discussing whether to pay off debt or invest in the market usually discuss comparing rates of return to make a decision. The thinking is that if you credit card debt costs 12% and you can earn 15% in the market, you are better off putting the money in the stock market. The problem with this approach is that it is not possible for most investors to consistently earn a rate in the stock market that is higher than their credit card interest rates. The stock market went a whole decade, 2000 until 2009, without any gain from the stock market averages.
Any bill vs. stock market consideration should include this primary directive: Get rid of your revolving debt. Revolving debt is your credit card balances and any other borrowed money where there is just a minimum payment due every month and the balances don't really go down over time. If you have received a lump sum of money and can pay off most or all of your credit card debt, make that your first priority and learn how to use credit cards for your financial benefit.
If you will use a monthly payment program to reduce your debt, you must make payments significantly larger than the credit card minimum payment. Divide your debt balances by the number of months in your goal to be debt free and add that amount to the minimum payment.
On the investing or stock market side of the equation, your retirement savings should have a level of importance with paying off your credit cards. If you have a 401(k) plan at work, this should be your first priority for saving and investing. If you have an IRA to provide additional retirement savings, it too should be funded and the money can be used in the stock market.