Skip to content

Commit f3846fb

Browse files
committed
added rot13 cipher
1 parent 9c726a7 commit f3846fb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Cipher/rot13.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function rot13(str) {
2+
var input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
3+
var output = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm";
4+
var index = (x) => input.indexOf(x);
5+
var translate = (x) => (index(x) > -1 ? output[index(x)] : x);
6+
return str.split("").map(translate).join("");
7+
}

0 commit comments

Comments
 (0)