Skip to content

Instantly share code, notes, and snippets.

@ardislu
Created May 8, 2024 04:26
Show Gist options
  • Save ardislu/8454b9758a8dbef594090c5ff2a63a22 to your computer and use it in GitHub Desktop.
Save ardislu/8454b9758a8dbef594090c5ff2a63a22 to your computer and use it in GitHub Desktop.
Golfed ROT13 in JavaScript.
// Ignores input casing, output will be all lowercase.
const r=s=>s.replace(/[a-z]/gi,c=>(((parseInt(c,36)+3)%26)+10).toString(36));
// r('the quick brown fox jumps over the lazy dog')
// 'gur dhvpx oebja sbk whzcf bire gur ynml qbt'
// r('gur dhvpx oebja sbk whzcf bire gur ynml qbt')
// 'the quick brown fox jumps over the lazy dog'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment