Last active
September 23, 2015 02:21
-
-
Save jtribble/45cecaa62465f61a0891 to your computer and use it in GitHub Desktop.
Is string a valid zip code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Is string a valid zip code? | |
* | |
* @param {string} str | |
* @return {boolean} | |
*/ | |
var isValidZip = function (str) { | |
return /(^\d{5}$)|(^\d{5}-\d{4}$)/.test(str); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment