# [SOLVED]Cubic Minefield: Javascript

Where real men cried.

``````function power(number, exponent) {
var total = 1;
while (power > 0) {
total += number;
power--;
}
}
``````

What bothers me is that the answer is probably so simple, but I have no idea what code to put.

Think about math! while doing powers, do you multiply or add? What should you minus? Power or total?

Wait where is this level? tell me so i can find it and work things out

Okay, i found the level

Alright, umâ€¦ Sansâ€¦

so to calculate the algorithm, you need to change the power variable to the exponent variable (since thatâ€™s what youâ€™re basing it from). and them multiply the total with the number. as well as assigning it to the total variable (multiply and assign).

to multiply variables in a code, you use this ( * ) key

hope this helps
Riley

hi @mayro, the times function above adds the number to the function, and you could also write it as

``````total = total + number
``````

now try to change the symbol to something that powers do â€¦

This is the error. Put this instead:

``````total = total * number;
``````

Does it work now?

it does, i was trying to make him figure it out, but anyway, yes, it does

1 Like

Dear All Big Brains of the Discourse,
I appreciate the help, but it took me some time to admit that I still canâ€™t comprehend what you mean at allâ€¦ YET. Could you explain in simpler terms?
Sincerely,
NutDealer

Wait a minuteâ€¦
oh my gosh. I just realized how simple it was. I literally spent a day on this.

2 Likes

There you should multiply number with himself for exponent times and you will get a number that it is in total.
For example, if number=2 and exponent=3, then total=222=8. Do you understand now?

have ou finished the level?

1 Like

I think soâ€¦ So have you finished the level, @mayro?