ajeshrkurup
10/7/2018 - 8:56 PM

power of a number

Calculate the number to a power, given number and power as input

//Write a function that takes 2 inputs,
// a number and power. Return the result after evaluating the power

function power(n, p) {
  if(p === 0) return 1;
  
  return (n * power(n, p-1));
}

console.log(power(3,3));