var tel = "123457890";
if (tel.length != 10) {
console.log("Sorry, incorrect format.");
} else {
var areaCode = tel.substring(0,3);
var prefix = tel.substring(3,6);
var suffix = tel.substring(6,10);
console.log("(" + areaCode + ") " + prefix + "-" + suffix);
}
Everything about this works for me except I can't get it to check for digits only. When I troubleshoot it with suggestions and run it through http://repl.it/languages/JavaScript I run into error messages.
i.e. When I put a "w" in with a string of 10 numerical digits I want it to return "Sorry, incorrect format" as if I had put in the wrong amount of numbers, etc.