Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. const bigN = 13
  2. const alphas = 26
  3. const lowerCaseA = 'a'.charCodeAt(0)
  4. const upperCaseA = 'A'.charCodeAt(0)
  5. const rotate = str => str
  6. .normalize('NFD')
  7. .split('')
  8. .map(chr => chr.charCodeAt(0))
  9. .map(charCode =>
  10. (lowerCaseA <= charCode && charCode < lowerCaseA + alphas) ? ((charCode - lowerCaseA + bigN) % alphas) + lowerCaseA :
  11. (upperCaseA <= charCode && charCode < upperCaseA + alphas) ? ((charCode - upperCaseA + bigN) % alphas) + upperCaseA :
  12. charCode
  13. )
  14. .map(charCode => String.fromCharCode(charCode))
  15. .join('')
  16.  
  17. const onChange = () => {
  18. const input = document.querySelector('.rot13__input')
  19. const output = document.querySelector('.rot13__output')
  20. output.value = rotate(input.value)
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement