Battery dies at 50%
So I just got a new iPhone and it has been working fine until now. I've only had it for a few days. Today, I was using the phone and it literally powered off at fifty percent. I plugged it in and it powered back on. It said the battery was dead. It charged again and got back up to fifty percent. It charged up really quickly. I took it off the charger and it hasn't done it again yet but I worry that it will. What should I do. Everything I found online said it was either a glitch and the phone just needed to be turned off and back on again or said that the phone needed a new battery. When I got the phone, it was dead and needed to charge. Could this be why?
Update: I powered it off and back on again and now it's at 48%. I'm really stressed because my brother wants my old phone and he needs it by Wednesday. I'm writing this on Sunday night. I'm kind of upset with Apple because this is a replacement device. They initially sent us a device with no software on it and they sent us this one in it's place and apparently, it may also be damaged. I have no idea why they're sending us broken devices but it's making me upset and is stressing me out. Please help me! I don't know what to do. The phone arrived on Friday for anyone who's wondering.
Update: It just did it again.
iPhone XS Max