SHARE
TWEET

Untitled

a guest Jun 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top