Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 042b0ce

Browse files
Create caesarscipher.js
1 parent 82531e0 commit 042b0ce

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎3. Caesars Cipher/caesarscipher.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function rot13(str) {
2+
const alphabets = "NOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
3+
4+
return str.split("").map((letter) => {
5+
const index = alphabets.lastIndexOf(letter)
6+
if (index === -1){
7+
return letter
8+
}
9+
return alphabets[index-13]
10+
}).join("")
11+
}
12+
13+
rot13("SERR PBQR PNZC");

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /