From 617ec6ba27cc6c4c4a833d94e5f4f429b26aa42d Mon Sep 17 00:00:00 2001 From: Suryapratap Singh Date: Tue, 7 Sep 2021 03:23:02 +0530 Subject: [PATCH] fix number checking --- Maths/CoPrimeCheck.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Maths/CoPrimeCheck.js b/Maths/CoPrimeCheck.js index 1bc3d32ce..f85cf8906 100644 --- a/Maths/CoPrimeCheck.js +++ b/Maths/CoPrimeCheck.js @@ -20,6 +20,10 @@ const GetEuclidGCD = require('./GetEuclidGCD') * @returns return correspond boolean value, if both number are co-prime return `true`, else return `false`. */ const CoPrimeCheck = (firstNumber, secondNumber) => { + // firstly, check that input is a number or not. + if (typeof firstNumber !== 'number' || typeof secondNumber !== 'number') { + return new TypeError('Argument is not a number.'); + } /* This is the most efficient algorithm for checking co-primes if the GCD of both the numbers is 1 that means they are co-primes.