Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const bigN = 13
- const alphas = 26
- const lowerCaseA = 'a'.charCodeAt(0)
- const upperCaseA = 'A'.charCodeAt(0)
- const rotate = str => str
- .normalize('NFD')
- .split('')
- .map(chr => chr.charCodeAt(0))
- .map(charCode =>
- (lowerCaseA <= charCode && charCode < lowerCaseA + alphas) ? ((charCode - lowerCaseA + bigN) % alphas) + lowerCaseA :
- (upperCaseA <= charCode && charCode < upperCaseA + alphas) ? ((charCode - upperCaseA + bigN) % alphas) + upperCaseA :
- charCode
- )
- .map(charCode => String.fromCharCode(charCode))
- .join('')
- const onChange = () => {
- const input = document.querySelector('.rot13__input')
- const output = document.querySelector('.rot13__output')
- output.value = rotate(input.value)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement