screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <title>Email Name Extraction</title> </head> <body> <h3>Javascript get name from email address</h3> <div id="nameContainer"></div> <script> function getNameFromEmail(email) { var name = email.substring(0, email.indexOf("@")); return name; } var emails = [ "john.doe@example.com", "jane.smith@example.com", "james.brown@example.com", ]; var nameContainer = document.getElementById("nameContainer"); for (var i = 0; i < emails.length; i++) { var email = emails[i]; var name = getNameFromEmail(email); var nameElement = document.createElement("p"); nameElement.textContent = name; nameContainer.appendChild(nameElement); } </script> </body> </html>