Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // tired brain
- var numUniqueEmails = function(emails) {
- let uniqueEmails = [];
- for(email of emails){
- let filtered = '';
- let atIndex = email.indexOf("@");
- let plusIndex = email.indexOf("+");
- let name = email.substring(email[0], atIndex);
- let domain = email.substring(atIndex, email.length);
- if(plusIndex > -1){
- name = name.substring(0, plusIndex)
- }
- name = (name.replace(/\./g, ''));
- filtered = name.concat(domain)
- if(!uniqueEmails.includes(filtered)) {
- uniqueEmails.push(filtered)
- }
- }
- return uniqueEmails.length
- };
Add Comment
Please, Sign In to add comment