Guest User

Untitled

a guest
Jan 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // tired brain
  2. var numUniqueEmails = function(emails) {
  3. let uniqueEmails = [];
  4.  
  5. for(email of emails){
  6. let filtered = '';
  7. let atIndex = email.indexOf("@");
  8. let plusIndex = email.indexOf("+");
  9. let name = email.substring(email[0], atIndex);
  10. let domain = email.substring(atIndex, email.length);
  11.  
  12. if(plusIndex > -1){
  13. name = name.substring(0, plusIndex)
  14. }
  15.  
  16. name = (name.replace(/\./g, ''));
  17. filtered = name.concat(domain)
  18.  
  19. if(!uniqueEmails.includes(filtered)) {
  20. uniqueEmails.push(filtered)
  21. }
  22. }
  23. return uniqueEmails.length
  24. };
Add Comment
Please, Sign In to add comment