Can I get a phone number formatted from 1234567891 to 123-456-7891 using 
Java script. I have written a function below which is returning  

1 234-567-891.Did i miss anything below.  

Your suggestion is appreciated a lot.  

Code below is writen in angular-moment.js file for custom filters. Which 
later on I will be using in HTML.

```
.filter('phonenumber', function() {
             return function (number) {
                 if (!number) { return ''; }
                 number = String(number);
                 var fNumber = number;

                 var c = (number[0] == '1') ? '1 ' : '';
                    number = number[0] == '1' ? number.slice(1):number;
                    var area = number.substring(0,3);
                    var front = number.substring(3, 6);
                    var end = number.substring(6, 10);

                    if (front) {
                        fNumber  = (c + "" + area + "-" + front);   
                    }
                    if (end) {
                        fNumber += ("-" + end);
                    }
                    return fNumber ;
                };
            })

```

Checking for first 3 numbers. This scenario is reproduced 
only when I enter first number as 1
Any guidance on how to implement this would be greatly appreciated.