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

10 lines
210 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function exp(b,n)
{
var ans = 1;
for (var i =1; i <= n; i++)
{
ans = b * ans;
}
return ans;
}
console.log(exp(2, 3));