programming-examples/js/Functions/Write a JavaScript function to compute the value of bn where n is the exponent and b is the bases. Accept b and n from the user and display the result..js
2019-11-15 12:59:38 +01:00

10 lines
210 B
JavaScript

function exp(b,n)
{
var ans = 1;
for (var i =1; i <= n; i++)
{
ans = b * ans;
}
return ans;
}
console.log(exp(2, 3));