Jump to content

US phone number format.

Go to solution Solved by PineyCreek,

US's country code is 1.  In example number XXX-YYY-ZZZZ, the X's are the area code, the Y's are the exchange number, and the Z's are the identifier.  Within the US (and likewise with other countries) the country code is usually not necessary except with particular phone systems.

 

This:

555-555-5555
(555)555-5555
(555) 555-5555
555 555 5555
5555555555
1 555 555 5555

 

Is just for convenience/formatting.  It might help someone remember a number better.  The spaces mean nothing, and the 1 can be ignored as it is the country code.  If dialing internationally you'll prefix the number with the country code, ex. Australia's country code is 61.

I am currently doing a freecodecamp algorithm challenge where I need to write a program to validate phone number.

 

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/telephone-number-validator

 

I am doing this challenge right now, the thing I want to ask has nothing to do with logic or coding.
I am not from the US, could someone explain the US phone number format a little bit?

There are a few example that are given from the quest:

 
Quote

555-555-5555
(555)555-5555
(555) 555-5555
555 555 5555
5555555555
1 555 555 5555

So, my understanding is that there are a few requirements:

  1. 10 digit with numbers only
  2. if the user added 1 in front of the 10 digit it counts too.

So, the thing I need to get rid of from the user inputs are non-number letter. What about 2 555 555 5555, is this a valid number??

If it is not broken, let's fix till it is. 

Link to comment
https://linustechtips.com/topic/1023992-us-phone-number-format/
Share on other sites

Link to post
Share on other sites

US's country code is 1.  In example number XXX-YYY-ZZZZ, the X's are the area code, the Y's are the exchange number, and the Z's are the identifier.  Within the US (and likewise with other countries) the country code is usually not necessary except with particular phone systems.

 

This:

555-555-5555
(555)555-5555
(555) 555-5555
555 555 5555
5555555555
1 555 555 5555

 

Is just for convenience/formatting.  It might help someone remember a number better.  The spaces mean nothing, and the 1 can be ignored as it is the country code.  If dialing internationally you'll prefix the number with the country code, ex. Australia's country code is 61.

Link to comment
https://linustechtips.com/topic/1023992-us-phone-number-format/#findComment-12215200
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×