Skip to content

Instantly share code, notes, and snippets.

@sakilk130
Last active May 30, 2021 14:29
Show Gist options
  • Save sakilk130/c39ac0373ebfe512c8bbfd0cece41f73 to your computer and use it in GitHub Desktop.
Save sakilk130/c39ac0373ebfe512c8bbfd0cece41f73 to your computer and use it in GitHub Desktop.

Revisions

  1. sakilk130 revised this gist May 30, 2021. No changes.
  2. sakilk130 created this gist May 30, 2021.
    7 changes: 7 additions & 0 deletions telephone-number-validator-freecodecamp.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    var re =
    /^([+]?1[\s]?)?((?:[(](?:[2-9]1[02-9]|[2-9][02-8][0-9])[)][\s]?)|(?:(?:[2-9]1[02-9]|[2-9][02-8][0-9])[\s.-]?)){1}([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2}[\s.-]?){1}([0-9]{4}){1}$/;

    function telephoneCheck(str) {
    return re.test(str);
    }
    telephoneCheck('555-555-5555');