mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 11:09:07 +01:00
17 lines
394 B
JavaScript
17 lines
394 B
JavaScript
function rot13(message) {
|
|
let result = "";
|
|
|
|
for (let character of message) {
|
|
let val = character.charCodeAt();
|
|
|
|
if (val >= 97 && val <= 122) {
|
|
result += String.fromCharCode(97 + (val - 97 + 13) % 26);
|
|
} else if (val >= 65 && val <= 90) {
|
|
result += String.fromCharCode(65 + (val - 65 + 13) % 26);
|
|
} else {
|
|
result += character;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|