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

Lines changed: 2 additions & 2 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy