13 lines
194 B
JavaScript
13 lines
194 B
JavaScript
var exponent = function(a, n)
|
|
{
|
|
if (n === 0)
|
|
{
|
|
return 1;
|
|
}
|
|
else
|
|
{
|
|
return a * exponent(a, n-1);
|
|
}
|
|
};
|
|
|
|
console.log(exponent(4, 2));
|