Hoodfc
1/9/2020 - 9:49 AM

Recursive power

Calculates the power with recursion

// calculates the power based on the given inputs - which are strictly positives in this example
// recursive solution [#10]
function power(base, pw){
    if(pw === 0) return 1;
    return base * power(base, --pw);
}