How to get text before @ in an email

How to get text before @ in an email

In this code, the split() method is used to split the email address "" at the "@" symbol, resulting in an array containing two elements: "john.doe" and "example.com".

The first element, which contains the username, is accessed by using the [0] index notation. The resulting username is then stored in the username variable and logged to the console.