Created
February 25, 2021 20:54
-
-
Save taciomedeiros/e9f3575c6043d5baa0aa140c5dc13629 to your computer and use it in GitHub Desktop.
Gist from mistakes.io
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 cardCode = '0000000000000000000000008650001144591116'; | |
| const cardCode2 = '8650001144591116'; | |
| const cardCode3 = '86500011445911160000'; | |
| const cardCode5 = '0000'; | |
| const extractCardCode= (_cardCode) => { | |
| if(_cardCode.startsWith('00')) { | |
| const _replaced = _cardCode.replace(/0{2,}/, '') | |
| if(!_replaced) return true; | |
| return `0${_replaced}` | |
| } | |
| return _cardCode; | |
| } | |
| extractCardCode(cardCode) | |
| extractCardCode(cardCode2) | |
| extractCardCode(cardCode3) | |
| extractCardCode(cardCode5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment