Skip to content

Commit b58c7ac

Browse files
authored
Update recursiveFunction.js
1 parent 1cbbac9 commit b58c7ac

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

05 - Objects-And-Functions/recursiveFunction.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,14 @@ var factorial = function (number) {
4343
};
4444

4545
console.log(`Factorial = ${factorial(9)}`);
46+
47+
48+
// Function
49+
function countDown(number) {
50+
if (number !== 0) countDown.count += number + countDown(number - 1);
51+
return countDown.count;
52+
}
53+
54+
countDown.count = 0;
55+
console.log(countDown(4));
56+

0 commit comments

Comments
 (0)