Skip to content

Commit dce5251

Browse files
committed
fix: check with builtin function
1 parent b7ef53c commit dce5251

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Recursive/Factorial.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ const factorial = (n) => {
1313
throw new TypeError('Not a Number')
1414
}
1515

16-
if ((n % 1) !== 0) {
16+
if (!Number.isInteger(n)) {
1717
throw new RangeError('Not a Whole Number')
1818
}
1919

2020
if (n < 0) {
21-
return new RangeError('Not a Positive Number')
21+
throw new RangeError('Not a Positive Number')
2222
}
2323

2424
if (n === 0) {

0 commit comments

Comments
 (0)