Programming concepts

Recursive base case

Try the free JavaScript compiler

A base case returns without another recursive call. Select a result consistent with the recursive recurrence, and ensure every allowed input progresses to a base case.

Formal Syntax & Structure

javascript syntaxjavascript
if (baseCondition) return baseValue;

Working Example

Example Snippetjavascript
function product(n){if(n===0)return 1;return n*product(n-1);}console.log(product(0),product(4));
JavaScript Reference