1function formatPhoneNumber(phoneNumberString) {
2 var cleaned = ('' + phoneNumberString).replace(/\D/g, '')
3 var match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/)
4 if (match) {
5 return '(' + match[1] + ') ' + match[2] + '-' + match[3]
6 }
7 return null
8}
9