diff --git a/Conversions/DateDayDifference.js b/Conversions/DateDayDifference.js index 4cf900089..b9d45e6dc 100644 --- a/Conversions/DateDayDifference.js +++ b/Conversions/DateDayDifference.js @@ -38,4 +38,4 @@ const DateDayDifference = (date1, date2) => { // Example : DateDayDifference('17/08/2002', '10/10/2020') => 6630 -module.exports = DateDayDifference +export { DateDayDifference } diff --git a/Conversions/DateToDay.js b/Conversions/DateToDay.js index 52d3be852..8683bdec4 100644 --- a/Conversions/DateToDay.js +++ b/Conversions/DateToDay.js @@ -61,4 +61,4 @@ const DateToDay = (date) => { // Example : DateToDay("18/12/2020") => Friday -module.exports = DateToDay +export { DateToDay } diff --git a/Conversions/LowerCaseConversion.js b/Conversions/LowerCaseConversion.js index 6ae481a7e..39ba9aba6 100644 --- a/Conversions/LowerCaseConversion.js +++ b/Conversions/LowerCaseConversion.js @@ -32,4 +32,4 @@ const LowerCaseConversion = (inputString) => { return newString.join('') } -module.exports = LowerCaseConversion +export { LowerCaseConversion } diff --git a/Conversions/RailwayTimeConversion.js b/Conversions/RailwayTimeConversion.js index 65f9836c3..dd06487e1 100644 --- a/Conversions/RailwayTimeConversion.js +++ b/Conversions/RailwayTimeConversion.js @@ -32,4 +32,4 @@ const RailwayTimeConversion = (timeString) => { } } -module.exports = RailwayTimeConversion +export { RailwayTimeConversion } diff --git a/Data-Structures/Tree/AVLTree.js b/Data-Structures/Tree/AVLTree.js index fc48f470f..e7f95f71c 100644 --- a/Data-Structures/Tree/AVLTree.js +++ b/Data-Structures/Tree/AVLTree.js @@ -234,39 +234,39 @@ const AVLTree = (function () { /** * A Code for Testing the AVLTree */ -(function test () { - const newAVL = new AVLTree() - const size = Math.floor(Math.random() * 1000000) - let uniques = 0 - let i, temp, j - const array = [] - for (i = 0; i < size; i++) { - temp = Math.floor(Math.random() * Number.MAX_VALUE) - if (newAVL.add(temp)) { - uniques++ - array.push(temp) - } - } - if (newAVL.size !== uniques) { - throw new Error('elements not inserted properly') - } - const findTestSize = Math.floor(Math.random() * uniques) - for (i = 0; i < findTestSize; i++) { - j = Math.floor(Math.random() * uniques) - if (!newAVL.find(array[j])) { - throw new Error('inserted elements not found') - } - } - const deleteTestSize = Math.floor(uniques * Math.random()) - for (i = 0; i < deleteTestSize; i++) { - j = Math.floor(Math.random() * uniques) - temp = array[j] - if (newAVL.find(temp)) { - if (!newAVL.remove(temp)) { - throw new Error('delete not working properly') - } - } - } -})() +// (function test () { +// const newAVL = new AVLTree() +// const size = Math.floor(Math.random() * 1000000) +// let uniques = 0 +// let i, temp, j +// const array = [] +// for (i = 0; i < size; i++) { +// temp = Math.floor(Math.random() * Number.MAX_VALUE) +// if (newAVL.add(temp)) { +// uniques++ +// array.push(temp) +// } +// } +// if (newAVL.size !== uniques) { +// throw new Error('elements not inserted properly') +// } +// const findTestSize = Math.floor(Math.random() * uniques) +// for (i = 0; i < findTestSize; i++) { +// j = Math.floor(Math.random() * uniques) +// if (!newAVL.find(array[j])) { +// throw new Error('inserted elements not found') +// } +// } +// const deleteTestSize = Math.floor(uniques * Math.random()) +// for (i = 0; i < deleteTestSize; i++) { +// j = Math.floor(Math.random() * uniques) +// temp = array[j] +// if (newAVL.find(temp)) { +// if (!newAVL.remove(temp)) { +// throw new Error('delete not working properly') +// } +// } +// } +// })() -module.exports = AVLTree +export { AVLTree } diff --git a/Hashes/SHA1.js b/Hashes/SHA1.js index 864ca392a..98cb03a44 100644 --- a/Hashes/SHA1.js +++ b/Hashes/SHA1.js @@ -170,8 +170,5 @@ function SHA1 (message) { return HH } -console.log(SHA1('A Test')) -console.log(SHA1('A Test')) - // export SHA1 function -module.exports = SHA1 +export { SHA1 } diff --git a/Hashes/SHA256.js b/Hashes/SHA256.js index d47dfb03e..61841e2ab 100644 --- a/Hashes/SHA256.js +++ b/Hashes/SHA256.js @@ -185,4 +185,4 @@ function SHA256 (message) { } // export SHA256 function -module.exports = SHA256 +export { SHA256 } diff --git a/Maths/CheckKishnamurthyNumber.js b/Maths/CheckKishnamurthyNumber.js index d030fff84..2a1f979d5 100644 --- a/Maths/CheckKishnamurthyNumber.js +++ b/Maths/CheckKishnamurthyNumber.js @@ -41,4 +41,4 @@ const CheckKishnamurthyNumber = (number) => { return sumOfAllDigitFactorial === number } -module.exports = CheckKishnamurthyNumber +export { CheckKishnamurthyNumber } diff --git a/Maths/CoPrimeCheck.js b/Maths/CoPrimeCheck.js index 11aa7b89b..d4a463a90 100644 --- a/Maths/CoPrimeCheck.js +++ b/Maths/CoPrimeCheck.js @@ -37,4 +37,4 @@ const CoPrimeCheck = (firstNumber, secondNumber) => { return GetEuclidGCD(firstNumber, secondNumber) === 1 } -module.exports = CoPrimeCheck +export { CoPrimeCheck } diff --git a/Maths/GetEuclidGCD.js b/Maths/GetEuclidGCD.js index 5eb51597b..3aff8dbbe 100644 --- a/Maths/GetEuclidGCD.js +++ b/Maths/GetEuclidGCD.js @@ -29,4 +29,4 @@ const GetEuclidGCD = (arg1, arg2) => { return (less) } -module.exports = GetEuclidGCD +export { GetEuclidGCD } diff --git a/Maths/ReverseNumber.js b/Maths/ReverseNumber.js index 4995761f3..2f29903c9 100644 --- a/Maths/ReverseNumber.js +++ b/Maths/ReverseNumber.js @@ -26,4 +26,4 @@ const ReverseNumber = (number) => { return reverseNumber } -module.exports = ReverseNumber +export { ReverseNumber } diff --git a/Maths/test/BinaryExponentiationRecursive.test.js b/Maths/test/BinaryExponentiationRecursive.test.js index 40ad20142..dc48d22d5 100644 --- a/Maths/test/BinaryExponentiationRecursive.test.js +++ b/Maths/test/BinaryExponentiationRecursive.test.js @@ -1,4 +1,4 @@ -const { binaryExponentiation } = require('../BinaryExponentiationRecursive') +import { binaryExponentiation } from '../BinaryExponentiationRecursive' describe('BinaryExponentiationRecursive', () => { it('should calculate 2 to the power of 10 correctly', () => { diff --git a/Project-Euler/Problem1.js b/Project-Euler/Problem001.js similarity index 61% rename from Project-Euler/Problem1.js rename to Project-Euler/Problem001.js index af3582f03..65a35e32a 100644 --- a/Project-Euler/Problem1.js +++ b/Project-Euler/Problem001.js @@ -4,8 +4,6 @@ Find the sum of all the multiples of 3 or 5 below the provided parameter value number. */ -const readline = require('readline') - const multiplesThreeAndFive = (num) => { let total = 0 // total for calculating the sum @@ -17,11 +15,4 @@ const multiplesThreeAndFive = (num) => { return total } -const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout -}) -rl.question('Enter a number: ', function (num) { - console.log(multiplesThreeAndFive(num)) // multiples3_5 function to calculate the sum of multiples of 3 and 5 within num - rl.close() -}) +export { multiplesThreeAndFive } diff --git a/String/AlternativeStringArrange.js b/String/AlternativeStringArrange.js index 9b722a1f9..b07b0a70d 100644 --- a/String/AlternativeStringArrange.js +++ b/String/AlternativeStringArrange.js @@ -41,4 +41,4 @@ const AlternativeStringArrange = (str1, str2) => { return outStr } -module.exports = AlternativeStringArrange +export { AlternativeStringArrange } diff --git a/String/CheckKebabCase.js b/String/CheckKebabCase.js index 30bbe976e..6e79ba6a5 100644 --- a/String/CheckKebabCase.js +++ b/String/CheckKebabCase.js @@ -17,4 +17,4 @@ const CheckKebabCase = (varName) => { return pat.test(varName) && !varName.includes('_') } -module.exports = CheckKebabCase +export { CheckKebabCase } diff --git a/String/CheckPascalCase.js b/String/CheckPascalCase.js index 6babce5f0..2e4c1ff3f 100644 --- a/String/CheckPascalCase.js +++ b/String/CheckPascalCase.js @@ -17,4 +17,4 @@ const CheckPascalCase = (VarName) => { return pat.test(VarName) } -module.exports = CheckPascalCase +export { CheckPascalCase }