Last active
February 20, 2019 13:58
-
-
Save OlivierJM/e853a6b6427a7c1669bc156fdd86f609 to your computer and use it in GitHub Desktop.
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
| // zambian mobile numbers start with 09x in case the user typed it start with a 2 | |
| // then its a country code prefixed | |
| // es6 | |
| const removePrefix = num => num[0] == 2 ? num.substring(3) : num[0] == 0 ? num.substring(1) : num; | |
| // es5 | |
| function removePrefix(num){ | |
| if(num[0] == 2){ // check if it starts with a 2 | |
| return num.substring(3) // remove numbers up to index 2 of the value | |
| } else if(num[0] == 0){ // check if the value starts with a zero | |
| return num.substring(1) // remove the o | |
| } | |
| return num | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment