Need help with Cubic Minefield


#1

I’m stuck on Cubic Minefield. I think i have the power function completed correctly, but it keeps returning an error that line 16 (function power(number, exponent) { ) has a Type Error: Can’t read protected property: findFriends. I’m really can’t figure out what i should do. I’ve pasted what i have below. Any help would be greatly appreciated!

// This function returns the number multiplied by the times
function mult(number, times) {
    var total = 0;
    while (times > 0) {
        total += number;
        times--;
    }
    return total;
}

// This function returns the number to the exponent power.
function power(number, exponent) {
    var total = 1;
    while (exponent > 0) {
        total *= number;
        exponent--;
    }
    return total;
}

// Don't change the follow code
var tower = this.findFriends()[0];
var a = tower.a;
var b = tower.b;
var c = tower.c;
var d = tower.d;
var x = hero.pos.x;

while (true) {
    var y = a * power(x, 3) + b * power(x, 2) + c * power(x, 1) + d * power(x, 0);
    hero.moveXY(x, y);
    x = x + 5;
}

#2

Apparently all i needed to do was post something and then the answer came magically to me. I just needed to upgrade my eyewear. Doh!


#3

Rubber Duck Syndrome :wink:

It’s so for me all time.