MCPcopy Create free account
hub / github.com/codecombat/codecombat / rot13

Function rot13

scripts/generateRot13Locale.js:7–13  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5const lines = text.split('\n');
6
7const rot13 = s => s.split('').map(function(char, index, chars) {
8 if (chars[index - 1] === '\\') { return char }
9 if (!char.match(/[A-Za-z]/)) { return char }
10 const c = Math.floor(char.charCodeAt(0) / 97);
11 const k = ((char.toLowerCase().charCodeAt(0) - 83) % 26) || 26;
12 return String.fromCharCode(k + ((c === 0) ? 64 : 96));
13}).join('');
14
15const output = lines.map(function(line, index) {
16 if (index === 0) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected