DEV Community

Cover image for Day 4 Challenge
Hello Dev World Blog
Hello Dev World Blog

Posted on • Originally published at hellodevworld.com

Day 4 Challenge

Happy day 4 of 365 days of coding! Write a function that accepts a string of numbers or a number and converts it to a phone number format.

Examples:

      phoneFormat(2359654144) //'235-965-4144'
      phoneFormat('2359654144') //'235-965-4144'
      phoneFormat(1234) //error: was not supplied enough numbers please pass a 10 digit number
      phoneFormat(23596541445) //error: was supplied too many numbers please pass a 10 digit number
Enter fullscreen mode Exit fullscreen mode

Top comments (0)