Created
September 11, 2018 17:59
-
-
Save samrocksc/6771936e86629c02c45d4b2e95afbb89 to your computer and use it in GitHub Desktop.
Sorting Things
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
import countryCodes from './countryCodes.json'; | |
const countryCallingCodeList = () => { | |
let codes = []; | |
countryCodes | |
.filter(country => { | |
if (country.countryCallingCodes.length === 0) { | |
return false; | |
} | |
return true; | |
}) | |
.forEach(country => { | |
const codeLists = country.countryCallingCodes.map(code => { | |
return { | |
value: code, | |
label: `${country.name}(${code})`, | |
}; | |
}); | |
codes = codes.concat(codeLists); | |
}); | |
return codes; | |
}; | |
export default countryCallingCodeList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment