-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostal-code-checker.js
More file actions
22 lines (20 loc) · 909 Bytes
/
postal-code-checker.js
File metadata and controls
22 lines (20 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
Title:
Russian postal code checker
Description:
You should write a simple function that takes string as input and checks if it is a valid Russian postal code, returning true or false.
A valid postcode should be 6 digits with no white spaces, letters or other symbols. Empty string should also return false.
Please also keep in mind that a valid post code cannot start with digit 0, 5, 7, 8 or 9
Valid postcode example 198328, 310003, 424000
Invalid postcode examples 12A483, 1@63, 111, 056879
Kata Link:
https://www.codewars.com/kata/russian-postal-code-checker
Discuss Link:
https://www.codewars.com/kata/russian-postal-code-checker/discuss
Solutions Link:
https://www.codewars.com/kata/russian-postal-code-checker/solutions
*/
// Long Solution
const zipvalidate = postcode => /^[12346]\d{5}$/g.test(postcode)
// Function Export
module.exports = zipvalidate