Skip to content

Commit 99ebb57

Browse files
committed
chore(totalIntegers): move helper function outside to prevent it being recreated
1 parent 0ad516b commit 99ebb57

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

15_totalIntegers/solution/totalIntegers-solution.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
// We could define this helper function inside of totalIntegers however that would not be best practice as everytime that the recursive totalIntegers is run it would re-create the isObject function when it could just re-use it.
2+
const isObject = (value) => typeof value === 'object' && value !== null;
3+
14
const totalIntegers = function (obj) {
25
let count = 0;
3-
const isObject = (value) => typeof value === 'object' && value !== null;
46

57
if (typeof obj !== 'object' || obj === null) {
68
return;

0 commit comments

Comments
 (0)