mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-07 02:05:08 +08:00
improve error handling of isDivisible
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
export const isDivisible = (num1, num2) => {
|
export const isDivisible = (num1, num2) => {
|
||||||
if (!Number.isFinite(num1) || !Number.isFinite(num2)) {
|
if (!Number.isFinite(num1) || !Number.isFinite(num2)) {
|
||||||
throw new Error('All parameters have to be numbers')
|
throw new TypeError("Expected a number")
|
||||||
}
|
}
|
||||||
if (num2 === 0) {
|
if (num2 === 0) {
|
||||||
return false
|
return false
|
||||||
|
Reference in New Issue
Block a user