You could use the super-short:
s.replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});
More Related Contents:
- How do I check if an array includes a value in JavaScript?
- Finding All Combinations (Cartesian product) of JavaScript array values
- How do you sort an array on multiple columns?
- How might I find the largest number contained in a JavaScript array?
- JavaScript – get the first day of the week from current date
- How to draw sky chart? [closed]
- Is it possible to get all arguments of a function as single object inside that function?
- Javascript – Generating all combinations of elements in a single array (in pairs)
- Fastest way to flatten / un-flatten nested JavaScript objects
- Does javascript process using an elastic racetrack algorithm
- What’s the algorithm to calculate aspect ratio?
- Bresenham algorithm in Javascript
- Javascript algorithm to find elements in array that are not in another array
- Permutations without recursive function call
- Packing different sized circles into rectangle – d3.js
- Using Canvas to animate a sorting algorithm in JS
- Calculating the shortest route between two points
- Sieve of Eratosthenes algorithm in JavaScript running endless for large number
- Find maximum possible time HH:MM by permuting four given digits
- Solving TicTacToe with minimax algorithm in Javascript
- How to implement a constraint solver for 2-D geometry?
- sort outer array based on values in inner array, javascript
- How to find horizon line efficiently in a high-altitude photo?
- Paint algorithm leaving white pixels at the edges when I color [duplicate]
- Finding all permutations of array elements as concatenated strings
- 3D point rotation algorithm
- Creating an array consisting of the largest values of each sub-array does not work as expected
- Randomizing elements in an array?
- Given an array, how to generate all combinations of subset size k?
- Two-sum Leetcode explanation, Hashmap, Javascript