79421746

Date: 2025-02-07 17:54:18
Score: 1
Natty:
Report link

You could just try looping through all the country codes and initializing the PhoneNumber until you get !== undefined. You don't actually need to know the country code, just whether it can be parsed and it's a valid number potentially, right?

You could order this Array of country codes by their likelihood, i.e. put US first followed by other North American ones, etc. (or however it makes sense for you).

I don't think performance will be such a problem in most cases, you could test it but it's all local calculations.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: ibrust