The law is, if an item is defective, the buyer can exchange it for another one of the same type within a given time period set by the retailer. I don't know if there's a minimum, but it's usually 14 or 30 days.
As for returing it and getting your money back, that's up to the individual retailer. They have a right to charge a "restocking fee" if they wish, as long as this policy is clearly posted in the store at the time of purchase.
Some retailers don't charge a restocking fee, some do. It's perfectly legal, because a lot of people buy something, then change their mind when the wife freaks, or they sober up, or any one of a hundred reasons, and you wouldn't want to buy a computer that had been opened now, would you?
You'd insist on a freshly sealed one, right?
If people were logical and reasonable, there would be no need for a restocking fee, but people are compulsive, and do things on the spur of the moment that they regret later. In that case, it shouldn't be the store's responsibility. If it were, all of us who actually think things through beforehand would have to pay for the others' mistakes, with higher prices. The buyer has to take some responsibility for his decision. It's part of life.