mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-07 19:17:33 +08:00
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:
@ -5,7 +5,7 @@ function euclideanGCDRecursive (first, second) {
|
||||
:param second: Second number
|
||||
:return: GCD of the numbers
|
||||
*/
|
||||
if (second == 0) {
|
||||
if (second === 0) {
|
||||
return first;
|
||||
} else {
|
||||
return euclideanGCDRecursive(second, (first % second));
|
||||
@ -19,7 +19,7 @@ function euclideanGCDIterative (first, second) {
|
||||
:param second: Second number
|
||||
:return: GCD of the numbers
|
||||
*/
|
||||
while (second != 0) {
|
||||
while (second !== 0) {
|
||||
let temp = second;
|
||||
second = first % second;
|
||||
first = temp;
|
||||
|
@ -27,12 +27,12 @@ function rot13(str) {
|
||||
}
|
||||
|
||||
}
|
||||
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
|
@ -4,7 +4,7 @@ function decimalToBinary(num) {
|
||||
bin.unshift(num % 2);
|
||||
num >>= 1; // basically /= 2 without remainder if any
|
||||
}
|
||||
console.log("The decimal in binary is " + bin.join(''));
|
||||
console.log("The decimal in binary is " + bin.join(""));
|
||||
}
|
||||
|
||||
decimalToBinary(2);
|
||||
|
@ -8,14 +8,14 @@
|
||||
function binarySearch(arr, i) {
|
||||
var mid = Math.floor(arr.length / 2);
|
||||
if (arr[mid] === i) {
|
||||
console.log('match', arr[mid], i);
|
||||
console.log("match", arr[mid], i);
|
||||
return arr[mid];
|
||||
} else if (arr[mid] < i && arr.length > 1) {
|
||||
binarySearch(arr.splice(mid, Number.MAX_VALUE), i);
|
||||
} else if (arr[mid] > i && arr.length > 1) {
|
||||
binarySearch(arr.splice(0, mid), i);
|
||||
} else {
|
||||
console.log('not found', i);
|
||||
console.log("not found", i);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user