Last active
January 23, 2017 22:18
-
-
Save tfogo/1426586a9d00ec95c5b1790500472d25 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPrimePhoneNumbers(isoCountry, areaCode) { | |
// ... | |
// Get the length of the country code so we know what to cut off from the number | |
let countryCodeLen = countries[isoCountry].code.length; | |
// assign the resolution of phonePromise to a variable | |
let primeNumberPromise = phonePromise.then(data => { | |
var verifiedPrimes = []; | |
data.forEach(twilioObject => { | |
twilioObject.available_phone_numbers.forEach(e => { | |
if (primality(e.phone_number.slice(countryCodeLen)) | |
&& !verifiedPrimes.includes(e.phone_number.slice(countryCodeLen))) { | |
// Slice off the country code using the length calculated above | |
verifiedPrimes.push(e.phone_number.slice(countryCodeLen)); | |
} | |
}) | |
}); | |
return verifiedPrimes; | |
}); | |
return primeNumberPromise; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment