<html>
<body>
//My text area
<textarea id="emailTextarea" rows ="30" cols="30" >
sara@yahoo.com
adam@yahoo.com
todd@yahoo.com
henry@yahoo.com
wright@yahoo.com
</textarea>
<p id="demo"></p>
<script>
//Getting input from the textarea for the email list
//The email list
var emailList = document.getElementById("emailTextarea").value;
//function to remove the yahoo extension
//remove the extension
var emailUserHash = emailList.reduce(function(emailUsers, email, i) {
var username = email.slice(0, email.indexOf('yahoo.com'));
if(!emailUsers[username]) emailUsers[username] = true;
return emailUsers;
}, {});
//calling the emailUserHash function
//call the emailUserHash function
var emailUsers = Object.keys(emailUserHash)
//Sort the email list
//sort the email list
emailUsers.sort();
//Print out the list
//output the list
document.write(emailUsers.join('</br>'));
</script>
</body>