Skip to content

Commit 6cf3aef

Browse files
committed
Problem 1 in recursion done, but returning extra number.
1 parent ca4950d commit 6cf3aef

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎recursion.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ while (n <= 10) {
1010
// write a recursive - function called countToTen that mimics the while loop above.
1111

1212
// code here
13+
let countToTen = (num) => {
14+
if (num > 10) return;
15+
console.log(num);
16+
countToTen(num + 1);
17+
}
18+
19+
countToTen(0);
1320

1421
// when you code is ready, un-comment the next line and run the file
1522
// console.log(countToTen());
@@ -29,5 +36,7 @@ console.log(factorial(5));
2936

3037
// write the above function in a recursive way.
3138

39+
40+
3241
// when your code is ready, un-comment the next line and run the file
3342
// console.log(recursiveFactorial());

0 commit comments

Comments
 (0)