On Facebook I was chatting a stranger girl the girl asked for the phone number I gave her. But when I asked her number she replied she does not have one. After a while, a WhatsApp message came having a code. She insisted me to give that code. I refused. Was it a scam?
1I don't. Know. What is. Question.– miike3459Feb 23, 2019 at 16:27
4She(He) was trying to gain control over your account. Even if she succeeds, re-registering WhatsApp again recovers the account so she couldn't have gained anything in few minutes.– defaltFeb 23, 2019 at 18:20
Can be anything from account recovery to banking transaction.– OvermindFeb 26, 2019 at 6:32
Yes, I'm sure they were trying to do something fishy, although I'm not sure I would call that a "scam", technically. They were probably actually trying to gain control of your account.
Codes are sent to your phone to verify that you actually have access to that phone. If you give those kinds of codes to somebody else, then they will be able to use them to prove they have access to your phone. As a result, the attacker might be able to access your email account even with two-step/two-factor authentication, or they might be able to access your whatsapp account, as might be the case in your situation.
I found the following article that might be relevant, it sounds like the same thing except that you received the request via Facebook.