npx standard --fix

This commit is contained in:
cclauss
2020-05-03 09:05:12 +02:00
parent e62ad2f73e
commit 856dc2f63c
47 changed files with 2240 additions and 2371 deletions

View File

@ -11,28 +11,26 @@
* @param {String} str - string to be decrypted
* @return {String} decrypted string
*/
function rot13(str) {
let response = [];
let strLength = str.length;
function rot13 (str) {
const response = []
const strLength = str.length
for (let i = 0; i < strLength; i++) {
const char = str.charCodeAt(i);
if (char < 65 || (char > 90 && char < 97) || char > 122) {
response.push(str.charAt(i));
} else if ((char > 77 && char <= 90) || (char > 109 && char <= 122)) {
response.push(String.fromCharCode(str.charCodeAt(i) - 13));
} else {
response.push(String.fromCharCode(str.charCodeAt(i) + 13));
}
for (let i = 0; i < strLength; i++) {
const char = str.charCodeAt(i)
if (char < 65 || (char > 90 && char < 97) || char > 122) {
response.push(str.charAt(i))
} else if ((char > 77 && char <= 90) || (char > 109 && char <= 122)) {
response.push(String.fromCharCode(str.charCodeAt(i) - 13))
} else {
response.push(String.fromCharCode(str.charCodeAt(i) + 13))
}
return response.join("");
}
return response.join('')
}
// Caesars Cipher Example
const encryptedString = "Uryyb Jbeyq";
const decryptedString = rot13(encryptedString);
const encryptedString = 'Uryyb Jbeyq'
const decryptedString = rot13(encryptedString)
console.log(decryptedString); // Hello World
console.log(decryptedString) // Hello World