Yes, the login code can let them register your account on another device unless additional protections stop it.
What should I do if a friend asks for a code?
Do not send it. Call them through a normal phone call or another channel because their account may already be compromised.
Why does someone want my WhatsApp code?
The 6-digit SMS code is the key to registering your number on a new phone. Whoever has it takes over your account and then scams your contacts in your name.
My WhatsApp was taken over. How do I get it back?
Reinstall WhatsApp, log in with your number, and request a new SMS code. That logs the attacker out. If they enabled two-step verification, follow WhatsApp’s recovery flow and warn your contacts meanwhile.
Does two-step verification stop this scam?
Largely yes. With a PIN set, the SMS code alone is not enough to move your account to a new device.