What is wrong with my code:
var emailExistence = require('email-existence');
var emails = ['klevisi@gmail.com', 'workingemail@gmail.com'];
var validEmails = [];
emails.forEach(function(email) {
emailExistence.check(email, function(err, res) {
if(res == true) {
validEmails.push(email); //No email is being added
console.log(email); //Emails are written to the console
}
});
});
validEmails.forEach(function(email) {
console.log(email); //Nothing is written to the console
});
The validEmails array isn't being populated.