Skip to content

thanhlvbk/reduceLeadsByEmail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

reduceLeadsByEmail

function validateEmail(email) {
var re = /^([\w-]+(?:.[\w-]+))@((?:[\w-]+.)\w[\w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i;
return re.test(email);
}

function reduceLeadsByEmail(dataEmails){
var result = [];
_.each(dataEmails,function(lead1){
if(!validateEmail(lead1))
return;
if(result.length === 0){
result.push(lead1);
return;
}
var v = .find(result, function(num){ return num === lead1; });
if(
.isUndefined(v))
result.push(lead1);
});
console.log(result);
}

var data = ["01@gmail.com", "02@gmail.com", "03@gmail.com", "01@gmail.com"];
reduceLeadsByEmail(data);

var data = ["01@gmail.com", "01@gmail.com", "01@gmail.com", "01@gmail.com"];
reduceLeadsByEmail(data);

var data = [];
reduceLeadsByEmail(data);

var data = ["01", "01@gmail.com"];
reduceLeadsByEmail(data);

var data = ["01", "02"];
reduceLeadsByEmail(data);

var data = [null, undefined];
reduceLeadsByEmail(data);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published