1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-22 08:33:48 +01:00
CodeWars/5kyu/rot13/solution.js

18 lines
394 B
JavaScript
Raw Permalink Normal View History

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;
}