Skip to content

Commit c1210aa

Browse files
authored
Update PerfectCube.js
Now `isInt` is replaced by `isFinite`, because `isInt` is a redundant check
1 parent 188a16e commit c1210aa

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Maths/PerfectCube.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
* Author: dephraiim
33
* License: GPL-3.0 or later
44
*
5-
* The integer check acts as a guard clause, and avoids calculating the root if the input is invalid,
6-
* it also ensures Infinity is treated as a non-cube.
75
* This uses `round` instead of `floor` or `trunc`, to guard against potential `cbrt` accuracy errors.
86
*/
97

10-
const perfectCube = (num) => Number.isInteger(num) && Math.round(Math.cbrt(num)) ** 3 === num
8+
const perfectCube = (num) => Number.isFinite(num) && Math.round(Math.cbrt(num)) ** 3 === num
119

1210
export { perfectCube }

0 commit comments

Comments
 (0)