Skip to content

Instantly share code, notes, and snippets.

@samrocksc
Created September 11, 2018 17:59
Show Gist options
  • Save samrocksc/6771936e86629c02c45d4b2e95afbb89 to your computer and use it in GitHub Desktop.
Save samrocksc/6771936e86629c02c45d4b2e95afbb89 to your computer and use it in GitHub Desktop.
Sorting Things
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