mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-22 00:23:47 +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;
|
|
}
|