Which two code snippets show working examples of a recursive function? Choose 2 answers

Which two code snippets show working examples of a recursive function? Choose 2 answers
A . Let countingDown = function(startNumber) {
If ( startNumber >0) {
console.log(startNumber) ;
return countingDown(startNUmber);
} else {
return startNumber;
}};

B . Function factorial ( numVar ) {
If (numVar < 0) return;
If ( numVar === 0 ) return 1;
return numVar -1;
C . Const sumToTen = numVar => {
If (numVar < 0)
Return;
return sumToTen(numVar + 1)};
D . Const factorial =numVar => {
If (numVar < 0) return;
If ( numVar === 0 ) return 1;
return numVar * factorial ( numVar – 1 );
};

Answer: A,D

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments