We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 39412da commit 99bf64cCopy full SHA for 99bf64c
README.md
@@ -109,32 +109,31 @@ Whenever a function calls itself, creating a loop.
109
1) Countdown
110
111
```javascript
112
-const countdown = num => {
113
- if (num > 0) {
114
- console.log(num);
115
- countdown(num - 1);
116
- }
117
-}
118
+const count = num => {
+ console.log(num)
+ num < 1
+ ? num
+ : count(num - 1)
+}
119
countdown(5);
120
/*
121
5
122
4
123
3
124
2
125
1
126
+0
127
*/
128
```
129
130
2) Factorial
131
132
-const factorial = num => {
133
- if (num <= 0) {
134
- return 1;
135
- } else {
136
- return (num * factorial(num - 1));
137
+const factorial = (num) =>
+ num <= 0
+ ? 1
+ : n * factorial(num - 1)
138
}
139
140
factorial(5);
0 commit comments