Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve ([params]) {
- let result = []
- params
- .split('&')
- .map(x => x.match(/^([A-Za-z\d]{25}|[A-Za-z\d]{16})$/))
- .filter(x => x)
- .forEach(x => {
- result.push(
- x[1]
- .toUpperCase()
- .split('')
- .map(x => (isNaN(x) ? x : 9 - Number(x)))
- .join('')
- .match(x[0].length === 16 ? /.{4}/g : /.{5}/g)
- .join('-')
- )
- })
- console.log(result.join(', '))
- }
Add Comment
Please, Sign In to add comment