Created
          December 23, 2021 01:48 
        
      - 
      
 - 
        
Save lopugit/5037831b893a69cce9d15529fd51cc8e to your computer and use it in GitHub Desktop.  
    Get Victorian State code based on a postcode
  
        
  
    
      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
    
  
  
    
  | const postcode = 9999 | |
| let state | |
| if ( | |
| (postcode >= 1000 && postcode <= 2599) || | |
| (postcode >= 2619 && postcode <= 2899) || | |
| (postcode >= 2921 && postcode <= 2999) | |
| ) { | |
| state = 'NSW' | |
| } else if ( | |
| (postcode >= 200 && postcode <= 299) || | |
| (postcode >= 2600 && postcode <= 2618) || | |
| (postcode >= 2900 && postcode <= 2920) | |
| ) { | |
| state = 'ACT' | |
| } else if ( | |
| (postcode >= 3000 && postcode <= 3999) || | |
| (postcode >= 8000 && postcode <= 8999) | |
| ) { | |
| state = 'VIC' | |
| } else if ( | |
| (postcode >= 4000 && postcode <= 4999) || | |
| (postcode >= 9000 && postcode <= 9999) | |
| ) { | |
| state = 'QLD' | |
| } else if ( | |
| (postcode >= 5000 && postcode <= 5999) | |
| ) { | |
| state = 'SA' | |
| } else if ( | |
| (postcode >= 6000 && postcode <= 6999) | |
| ) { | |
| state = 'WA' | |
| } else if ( | |
| (postcode >= 7000 && postcode <= 7999) | |
| ) { | |
| state = 'TAS' | |
| } else if ( | |
| (postcode >= 800 && postcode <= 999) | |
| ) { | |
| state = 'NT' | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment