You are viewing a single comment's thread. Return to all comments →
var n = parseInt(readLine()); var s = readLine(); var k = parseInt(readLine()); let finalString = '' for (let letter of s) { let letra = '' if (letter.match(/[a-z]/i)) { let asciiL = letter.charCodeAt(0) if (asciiL >= 65 && asciiL <= 90) { letra = String.fromCharCode(65 + (asciiL - 65 + k) % 26) } if (asciiL >= 97 && asciiL <= 122) { letra = String.fromCharCode(97 + (asciiL - 97 + k) % 26) } } else { letra = letter } finalString += letra } console.log(finalString)
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher: Encryption
You are viewing a single comment's thread. Return to all comments →