Fixed Whitespace, Operators, and Quotes to Comply with JSLint

I modified the whitespace in the files and changed single quotes to double quotes.

I also changed some `==` and `!=` operators to `===` and `!==` to comply with JSLint.
This commit is contained in:
PatOnTheBack
2019-06-27 10:41:44 -04:00
parent 2c1cd5595a
commit f37cac8508
8 changed files with 143 additions and 143 deletions

View File

@ -1,6 +1,6 @@
/**
* Caesar's Cipher - also known as the ROT13 Cipher is when
* a letter is replaced by the one that is 13 spaces away
* a letter is replaced by the one that is 13 spaces away
* from it in the alphabet. If the letter is in the first half
* of the alphabet we add 13, if it's in the latter half we
* subtract 13 from the character code value.
@ -12,27 +12,27 @@
* @return {String} decrypted string
*/
function rot13(str) {
let response = [];
let strLength = str.length;
let response = [];
let strLength = str.length;
for (let i =0; i < strLength; i++) {
const char = str.charCodeAt(i);
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));
}
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 encryptedString = "Uryyb Jbeyq";
const decryptedString = rot13(encryptedString);
console.log(decryptedString); // Hello World
console.log(decryptedString); // Hello World