diff --git a/Cache/Memoize.js b/Cache/Memoize.js index 94bc0f28e..5b87cee1e 100644 --- a/Cache/Memoize.js +++ b/Cache/Memoize.js @@ -30,7 +30,7 @@ const memoize = (func, cache = new Map()) => { /** * Arguments converted to JSON string for use as a key of Map - it's easy to detect collections like -> Object and Array * If the args input is -> [new Set([1, 2, 3, 4]), {name: 'myName', age: 23}] - * Then the agrsKey generate to -> '[[1,2,3,4],{"name":"myName","age":23}]' which is JSON mean string + * Then the argsKey generate to -> '[[1,2,3,4],{"name":"myName","age":23}]' which is JSON mean string * Now it's ready to be a perfect key for Map */ const argsKey = JSON.stringify(args, jsonReplacer) diff --git a/Ciphers/test/AffineCipher.test.js b/Ciphers/test/AffineCipher.test.js index 51d9cb700..e044f1b41 100644 --- a/Ciphers/test/AffineCipher.test.js +++ b/Ciphers/test/AffineCipher.test.js @@ -19,7 +19,7 @@ describe('Test Affine Cipher', () => { expect(() => encrypt('null', 4, 1)).toThrow() }) - it('Test - 3 Pass string value to encrypt and ecrypt function', () => { + it('Test - 3 Pass string value to encrypt and decrypt function', () => { expect(decrypt(encrypt('HELLO WORLD', 5, 8), 5, 8)).toBe('HELLO WORLD') expect(decrypt(encrypt('ABC DEF', 3, 5), 3, 5)).toBe('ABC DEF') expect(decrypt(encrypt('Brown fox jump over the fence', 7, 3), 7, 3)).toBe( diff --git a/Ciphers/test/KeywordShiftedAlphabet.test.js b/Ciphers/test/KeywordShiftedAlphabet.test.js index 7cc7c4820..7fd153c97 100644 --- a/Ciphers/test/KeywordShiftedAlphabet.test.js +++ b/Ciphers/test/KeywordShiftedAlphabet.test.js @@ -1,12 +1,12 @@ import { encrypt, decrypt } from '../KeywordShiftedAlphabet' -test('Hello world! === dcrypt(encrypt(Hello world!))', () => { +test('Hello world! === decrypt(encrypt(Hello world!))', () => { const word = 'Hello world!' const result = decrypt('keyword', encrypt('keyword', word)) expect(result).toMatch(word) }) -test('The Algorithms === dcrypt(encrypt(The Algorithms))', () => { +test('The Algorithms === decrypt(encrypt(The Algorithms))', () => { const word = 'The Algorithms' const result = decrypt('keyword', encrypt('keyword', word)) expect(result).toMatch(word) diff --git a/Ciphers/test/VigenereCipher.test.js b/Ciphers/test/VigenereCipher.test.js index de8618b8c..83ba40504 100644 --- a/Ciphers/test/VigenereCipher.test.js +++ b/Ciphers/test/VigenereCipher.test.js @@ -1,12 +1,12 @@ import { encrypt, decrypt } from '../VigenereCipher' -test('Hello world! === dcrypt(encrypt(Hello world!))', () => { +test('Hello world! === decrypt(encrypt(Hello world!))', () => { const word = 'Hello world!' const result = decrypt(encrypt(word, 'code'), 'code') expect(result).toMatch(word) }) -test('The Algorithms === dcrypt(encrypt(The Algorithms))', () => { +test('The Algorithms === decrypt(encrypt(The Algorithms))', () => { const word = 'The Algorithms' const result = decrypt(encrypt(word, 'code'), 'code') expect(result).toMatch(word) diff --git a/Conversions/BinaryToHex.js b/Conversions/BinaryToHex.js index 71b32cc2f..27c9ccbac 100644 --- a/Conversions/BinaryToHex.js +++ b/Conversions/BinaryToHex.js @@ -29,7 +29,7 @@ const hexLookup = (bin) => { } const binaryToHex = (binaryString) => { /* - Function for convertung Binary to Hex + Function for converting Binary to Hex 1. The conversion will start from Least Significant Digit (LSB) to the Most Significant Bit (MSB). 2. We divide the bits into sections of 4-bits starting from LSB to MSB. diff --git a/Conversions/RailwayTimeConversion.js b/Conversions/RailwayTimeConversion.js index 2537cf449..3d47a4827 100644 --- a/Conversions/RailwayTimeConversion.js +++ b/Conversions/RailwayTimeConversion.js @@ -21,9 +21,9 @@ const RailwayTimeConversion = (timeString) => { return new TypeError('Argument is not a string.') } // split the string by ':' character. - const [hour, minute, scondWithShift] = timeString.split(':') + const [hour, minute, secondWithShift] = timeString.split(':') // split second and shift value. - const [second, shift] = [scondWithShift.substr(0, 2), scondWithShift.substr(2)] + const [second, shift] = [secondWithShift.substr(0, 2), secondWithShift.substr(2)] // convert shifted time to not-shift time(Railway time) by using the above explanation. if (shift === 'PM') { if (parseInt(hour) === 12) { return `${hour}:${minute}:${second}` } else { return `${parseInt(hour) + 12}:${minute}:${second}` } diff --git a/Conversions/test/TemperatureConversion.test.js b/Conversions/test/TemperatureConversion.test.js index df8af0db4..50626bec8 100644 --- a/Conversions/test/TemperatureConversion.test.js +++ b/Conversions/test/TemperatureConversion.test.js @@ -80,19 +80,19 @@ describe('Testing Conversion of Rankine to Kelvin', () => { expect(test1).toBe(6) }) }) -describe('Testing Conversion of Reamur to Celsius', () => { - it('with Reamur value', () => { +describe('Testing Conversion of Reaumur to Celsius', () => { + it('with Reaumur value', () => { const test1 = tc.reaumurToCelsius(100) expect(test1).toBe(125) }) }) -describe('Testing Conversion of Reamur to Fahrenheit', () => { - it('with Reamur value', () => { +describe('Testing Conversion of Reaumur to Fahrenheit', () => { + it('with Reaumur value', () => { const test1 = tc.reaumurToFahrenheit(100) expect(test1).toBe(257) }) }) -describe('Testing Conversion of Reamur to Kelvin', () => { +describe('Testing Conversion of Reaumur to Kelvin', () => { it('with Reamur value', () => { const test1 = tc.reaumurToKelvin(100) expect(test1).toBe(398) diff --git a/Data-Structures/Array/LocalMaximomPoint.js b/Data-Structures/Array/LocalMaximomPoint.js index c19985614..de136c21f 100644 --- a/Data-Structures/Array/LocalMaximomPoint.js +++ b/Data-Structures/Array/LocalMaximomPoint.js @@ -3,7 +3,7 @@ * * Notes: * - works by using divide and conquer - * - the function gets the array A with n Real numbersand returns the local max point index (if more than one exists return the first one) + * - the function gets the array A with n Real numbers and returns the local max point index (if more than one exists return the first one) * * @complexity: O(log(n)) (on average ) * @complexity: O(log(n)) (worst case) diff --git a/Data-Structures/Tree/Trie.js b/Data-Structures/Tree/Trie.js index 04603f63b..90d7944f6 100644 --- a/Data-Structures/Tree/Trie.js +++ b/Data-Structures/Tree/Trie.js @@ -83,8 +83,8 @@ Trie.prototype.remove = function (word, count) { if (child.count >= count) child.count -= count else child.count = 0 - // If some occurrences are left we dont delete it or else - // if the object forms some other objects prefix we dont delete it + // If some occurrences are left we don't delete it or else + // if the object forms some other objects prefix we don't delete it // For checking an empty object // https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object if (child.count <= 0 && (Object.keys(child.children).length && child.children.constructor === Object)) { @@ -110,7 +110,7 @@ Trie.prototype.contains = function (word) { return true } -Trie.prototype.findOccurences = function (word) { +Trie.prototype.findOccurrences = function (word) { // find the node with given prefix const node = this.findPrefix(word) // No such word exists diff --git a/Dynamic-Programming/KadaneAlgo.js b/Dynamic-Programming/KadaneAlgo.js index a4c423e0f..6f45e675a 100644 --- a/Dynamic-Programming/KadaneAlgo.js +++ b/Dynamic-Programming/KadaneAlgo.js @@ -1,6 +1,6 @@ /* Kadane's algorithm is one of the most efficient ways to * calculate the maximum contiguous subarray sum for a given array. - * Below is the implementation of kadanes's algorithm along with + * Below is the implementation of Kadane's algorithm along with * some sample test cases. * There might be a special case in this problem if al the elements * of the given array are negative. In such a case, the maximum negative @@ -10,14 +10,14 @@ */ export function kadaneAlgo (array) { - let cummulativeSum = 0 + let cumulativeSum = 0 let maxSum = Number.NEGATIVE_INFINITY // maxSum has the least possible value for (let i = 0; i < array.length; i++) { - cummulativeSum = cummulativeSum + array[i] - if (maxSum < cummulativeSum) { - maxSum = cummulativeSum - } else if (cummulativeSum < 0) { - cummulativeSum = 0 + cumulativeSum = cumulativeSum + array[i] + if (maxSum < cumulativeSum) { + maxSum = cumulativeSum + } else if (cumulativeSum < 0) { + cumulativeSum = 0 } } return maxSum diff --git a/Dynamic-Programming/UniquePaths2.js b/Dynamic-Programming/UniquePaths2.js index 52bf9d08b..14bc1e6d7 100644 --- a/Dynamic-Programming/UniquePaths2.js +++ b/Dynamic-Programming/UniquePaths2.js @@ -63,7 +63,7 @@ const uniquePaths2 = (obstacles) => { grid[0][j] = 1 } // Fill the rest of grid by dynamic programming - // using following reccurent formula: + // using following recurrent formula: // K[i][j] = K[i - 1][j] + K[i][j - 1] for (let i = 1; i < rows; i++) { for (let j = 1; j < columns; j++) { diff --git a/Geometry/Circle.js b/Geometry/Circle.js index 4b4f8e3b9..9e06527c9 100644 --- a/Geometry/Circle.js +++ b/Geometry/Circle.js @@ -2,7 +2,7 @@ * This class represents a circle and can calculate it's perimeter and area * https://en.wikipedia.org/wiki/Circle * @constructor - * @param {number} radius - The radius of the circule. + * @param {number} radius - The radius of the circle. */ export default class Circle { constructor (radius) { diff --git a/Graphs/BinaryLifting.js b/Graphs/BinaryLifting.js index 40d664ba3..4ab9baa5a 100644 --- a/Graphs/BinaryLifting.js +++ b/Graphs/BinaryLifting.js @@ -3,7 +3,7 @@ * Binary Lifting implementation in Javascript * Binary Lifting is a technique that is used to find the kth ancestor of a node in a rooted tree with N nodes * The technique requires preprocessing the tree in O(N log N) using dynamic programming - * The techniqe can answer Q queries about kth ancestor of any node in O(Q log N) + * The technique can answer Q queries about kth ancestor of any node in O(Q log N) * It is faster than the naive algorithm that answers Q queries with complexity O(Q K) * It can be used to find Lowest Common Ancestor of two nodes in O(log N) * Tutorial on Binary Lifting: https://codeforces.com/blog/entry/100826 diff --git a/Graphs/LCABinaryLifting.js b/Graphs/LCABinaryLifting.js index 211f22f24..7855b552c 100644 --- a/Graphs/LCABinaryLifting.js +++ b/Graphs/LCABinaryLifting.js @@ -1,6 +1,6 @@ /** * Author: Adrito Mukherjee - * Findind Lowest Common Ancestor By Binary Lifting implementation in JavaScript + * Finding Lowest Common Ancestor By Binary Lifting implementation in JavaScript * The technique requires preprocessing the tree in O(N log N) using dynamic programming) * It can be used to find Lowest Common Ancestor of two nodes in O(log N) * Tutorial on Lowest Common Ancestor: https://www.geeksforgeeks.org/lca-in-a-tree-using-binary-lifting-technique diff --git a/Maths/BinomialCoefficient.js b/Maths/BinomialCoefficient.js index f445c8fb6..ff12a38ab 100644 --- a/Maths/BinomialCoefficient.js +++ b/Maths/BinomialCoefficient.js @@ -7,7 +7,7 @@ /** * @function findBinomialCoefficient - * @description -> this function returns bonimial coefficient + * @description -> this function returns binomial coefficient * of two numbers n & k given by n!/((n-k)!k!) * @param {number} n * @param {number} k diff --git a/Maths/CheckKishnamurthyNumber.js b/Maths/CheckKishnamurthyNumber.js index 2a1f979d5..7a0cc9a0c 100644 --- a/Maths/CheckKishnamurthyNumber.js +++ b/Maths/CheckKishnamurthyNumber.js @@ -37,7 +37,7 @@ const CheckKishnamurthyNumber = (number) => { sumOfAllDigitFactorial += factorial(lastDigit) newNumber = Math.floor(newNumber / 10) } - // if the sumOftheFactorial is equal to the given number it means the number is a Krishnamurthy number. + // if the sumOfAllDigitFactorial is equal to the given number it means the number is a Krishnamurthy number. return sumOfAllDigitFactorial === number } diff --git a/Maths/ExtendedEuclideanGCD.js b/Maths/ExtendedEuclideanGCD.js index c666a9989..80812351e 100644 --- a/Maths/ExtendedEuclideanGCD.js +++ b/Maths/ExtendedEuclideanGCD.js @@ -1,7 +1,7 @@ /** * Problem statement and explanation: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm * - * This algorithm plays an important role for modular arithmetic, and by extension for cyptography algorithms + * This algorithm plays an important role for modular arithmetic, and by extension for cryptography algorithms * * Basic explanation: * The Extended Euclidean algorithm is a modification of the standard Euclidean GCD algorithm. diff --git a/Maths/FermatPrimalityTest.js b/Maths/FermatPrimalityTest.js index 1df78e339..331c168ee 100644 --- a/Maths/FermatPrimalityTest.js +++ b/Maths/FermatPrimalityTest.js @@ -21,7 +21,7 @@ * 1 / 2^50 = 8.8 * 10^-16 (a pretty small number) * * For comparison, the probability of a cosmic ray causing an error to your - * infalible program is around 1.4 * 10^-15. An order of magnitude below! + * infallible program is around 1.4 * 10^-15. An order of magnitude below! * * But because nothing is perfect, there's a major flaw to this algorithm, and * the cause are the so called Carmichael Numbers. These are composite numbers n diff --git a/Maths/test/MeanAbsoluteDeviation.test.js b/Maths/test/MeanAbsoluteDeviation.test.js index 33fa38d2f..d44eb7d06 100644 --- a/Maths/test/MeanAbsoluteDeviation.test.js +++ b/Maths/test/MeanAbsoluteDeviation.test.js @@ -9,7 +9,7 @@ describe('tests for mean absolute deviation', () => { expect(() => meanAbsoluteDeviation('fgh')).toThrow() }) - it('should return the mean absolute devition of an array of numbers', () => { + it('should return the mean absolute deviation of an array of numbers', () => { const meanAbDev = meanAbsoluteDeviation([2, 34, 5, 0, -2]) expect(meanAbDev).toBe(10.479999999999999) }) diff --git a/Project-Euler/Problem003.js b/Project-Euler/Problem003.js index 789f62206..d61c9ad5f 100644 --- a/Project-Euler/Problem003.js +++ b/Project-Euler/Problem003.js @@ -1,18 +1,18 @@ // https://projecteuler.net/problem=3 export const largestPrime = (num = 600851475143) => { - let newnumm = num + let newnum = num let largestFact = 0 let counter = 2 - while (counter * counter <= newnumm) { - if (newnumm % counter === 0) { - newnumm = newnumm / counter + while (counter * counter <= newnum) { + if (newnum % counter === 0) { + newnum = newnum / counter } else { counter++ } } - if (newnumm > largestFact) { - largestFact = newnumm + if (newnum > largestFact) { + largestFact = newnum } return largestFact } diff --git a/Project-Euler/Problem008.js b/Project-Euler/Problem008.js index 4c1c71927..5012dc3e5 100644 --- a/Project-Euler/Problem008.js +++ b/Project-Euler/Problem008.js @@ -2,11 +2,11 @@ const largestAdjacentNumber = (grid, consecutive) => { grid = grid.split('\n').join('') - const splitedGrid = grid.split('\n') + const splitGrid = grid.split('\n') let largestProd = 0 - for (const row in splitedGrid) { - const currentRow = splitedGrid[row].split('').map(x => Number(x)) + for (const row in splitGrid) { + const currentRow = splitGrid[row].split('').map(x => Number(x)) for (let i = 0; i < currentRow.length - consecutive; i++) { const combine = currentRow.slice(i, i + consecutive) diff --git a/Project-Euler/Problem023.js b/Project-Euler/Problem023.js index 606318b80..32f35a8bf 100644 --- a/Project-Euler/Problem023.js +++ b/Project-Euler/Problem023.js @@ -14,7 +14,7 @@ */ /** - * collect the abundant numbers, generate and store their sums with each other, and check for numbers not in the llst of sums, adds them and returns their sum. + * collect the abundant numbers, generate and store their sums with each other, and check for numbers not in the list of sums, adds them and returns their sum. * @param {number} [n = 28123] * @returns {number} */ diff --git a/Project-Euler/Problem028.js b/Project-Euler/Problem028.js index e55f31b95..998f0f2fb 100644 --- a/Project-Euler/Problem028.js +++ b/Project-Euler/Problem028.js @@ -40,7 +40,7 @@ function problem28 (dim) { * Third corner: i^2 - 2 * (i - 1) * Fourth corner: i^2 - 3 * (i - 1) * - * Doing the sum of each corner and simplifing, we found that the result for each dimension is: + * Doing the sum of each corner and simplifying, we found that the result for each dimension is: * sumDim = 4 * i^2 + 6 * (1 - i) * * In this case I skip the 1x1 dim matrix because is trivial, that's why I start in a 3x3 matrix diff --git a/Sorts/IntroSort.js b/Sorts/IntroSort.js index e3a605f4a..d5d79a328 100644 --- a/Sorts/IntroSort.js +++ b/Sorts/IntroSort.js @@ -1,5 +1,5 @@ /** - * @function Intosort (As implemented in STD C++ Lib) + * @function Introsort (As implemented in STD C++ Lib) * The function performs introsort which is used in * C++ Standard LIbrary, the implementation is inspired from] * library routine itself. @@ -88,7 +88,7 @@ function introsort (array, compare) { const THRESHOLD = 16 /** * @constant TUNEMAXDEPTH - * Constant usec to increase or decrease value + * Constant used to increase or decrease value * of maxDepth */ const TUNEMAXDEPTH = 1