how to call a function in recursion in javascript code example
Example: recursive function javascript
function pow(x, n) {
if (n == 1) {
return x;
} else {
return x * pow(x, n - 1);
}
}
alert( pow(3, 3) ); // 27
function pow(x, n) {
if (n == 1) {
return x;
} else {
return x * pow(x, n - 1);
}
}
alert( pow(3, 3) ); // 27