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 fb8f397 commit 86a7806Copy full SHA for 86a7806
more-on-functions/chapter-examples/recursion-base-case/factorial.js
@@ -1,13 +1,12 @@
1
//The following concept check assumes that only positive integers are passed to the function.
2
3
function factorial(integer){
4
- if (/*enter base case test here*/){
5
- return integer;
+ if (integer < 5){
+ console.log(integer);
6
} else {
7
return integer*(factorial(integer-1));
8
}
9
10
11
-console.log(factorial(4));
12
13
//Skill boost! Add validation to return an error message if the function is passed a string, negative number or a decimal value.
0 commit comments