{"ScriptPreparationCode":null,"TestCases":[{"Name":"math ","Code":"const CaesarCipher = function (shift) {\r\n const code = (str, shift) =\u003E\r\n str.toUpperCase().replace(/[A-Z]/g, val =\u003E String.fromCharCode(65 \u002B (val.charCodeAt() \u002B shift - 65) % 26));\r\n this.encode = str =\u003E\r\n code(str, shift);\r\n this.decode = str =\u003E\r\n code(str, 26 - shift);\r\n};\r\n\r\nconst c = new CaesarCipher(5);\r\nc.encode(\u0027Codewars\u0027)\r\nc.decode(\u0027HTIJBFWX\u0027)","IsDeferred":false},{"Name":"condition","Code":"var CaesarCipher = function (shift) {\r\n this.shiftChar = (str, offset) =\u003E\r\n str.replace(/[a-z]/gi, (c) =\u003E {\r\n let charCode = c.toUpperCase().charCodeAt(0) \u002B offset;\r\n if (charCode \u003C 65) charCode \u002B= 26;\r\n else if (charCode \u003E 90) charCode -= 26;\r\n return String.fromCharCode(charCode);\r\n });\r\n\r\n this.encode = (str) =\u003E this.shiftChar(str, shift);\r\n this.decode = (str) =\u003E this.shiftChar(str, -shift);\r\n};\r\n\r\n\r\nconst c = new CaesarCipher(5);\r\nc.encode(\u0027Codewars\u0027)\r\nc.decode(\u0027HTIJBFWX\u0027)","IsDeferred":false}]}