Undefined help


I don't know what's wrong. I'm trying to make a function that takes the power of a number but I get undefined instead of the result.

function power (base, exponent) {
        for (var k=0; k<exponent; k++) {
            var multiply=[];

        for (var i=0; i<multiply.length; i++) {
            sum = 1;
            sum = sum * multiply[i];


You're printing the result of calling your function, but your function doesn't produce a result - so what you end up printing is undefined, because the result wasn't defined


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.