Skip to content

Commit 617ec6b

Browse files
fix number checking
1 parent d79e2f7 commit 617ec6b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Maths/CoPrimeCheck.js

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const GetEuclidGCD = require('./GetEuclidGCD')
2020
* @returns return correspond boolean value, if both number are co-prime return `true`, else return `false`.
2121
*/
2222
const CoPrimeCheck = (firstNumber, secondNumber) => {
23+
// firstly, check that input is a number or not.
24+
if (typeof firstNumber !== 'number' || typeof secondNumber !== 'number') {
25+
return new TypeError('Argument is not a number.');
26+
}
2327
/*
2428
This is the most efficient algorithm for checking co-primes
2529
if the GCD of both the numbers is 1 that means they are co-primes.

0 commit comments

Comments
 (0)