# \[SOLVED\]Cubic Minefield: Javascript

**URL:** https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283
**Category:** Level Help
**Created:** [June 16, 2020, 8:06pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283 "2020-06-16T20:06:34Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![mayro](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mayro/32/12816_2.png) [@mayro](https://discourse.codecombat.com/u/mayro)
#### Post date: [June 16, 2020, 8:06pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/1 "2020-06-16T20:06:34Z")

</div>

Where real men cried.

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

```

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

---

<div class="post-metadata">

### Author: ![EpicCoder999](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/epiccoder999/32/12768_2.png) [@EpicCoder999](https://discourse.codecombat.com/u/EpicCoder999)
#### Post date: [June 16, 2020, 9:22pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/2 "2020-06-16T21:22:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Valentino\_Artawan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/valentino_artawan/32/12153_2.png) [@Valentino\_Artawan](https://discourse.codecombat.com/u/Valentino_Artawan)
#### Post date: [June 16, 2020, 11:54pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/3 "2020-06-16T23:54:15Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Valentino\_Artawan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/valentino_artawan/32/12153_2.png) [@Valentino\_Artawan](https://discourse.codecombat.com/u/Valentino_Artawan)
#### Post date: [June 17, 2020, 12:02am UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/4 "2020-06-17T00:02:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)
#### Post date: [June 17, 2020, 10:48am UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/5 "2020-06-17T10:48:32Z")

</div>

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

```python
total = total + number

```

now try to change the symbol to something that powers do …

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [June 17, 2020, 10:53am UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/6 "2020-06-17T10:53:12Z")

</div>

> [@mayro](#):
>
> `total += number;`

This is the error. Put this instead:

```python
total = total * number;

```

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [June 17, 2020, 10:54am UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/7 "2020-06-17T10:54:22Z")

</div>

Does it work now? 🤨

---

<div class="post-metadata">

### Author: ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)
#### Post date: [June 17, 2020, 12:33pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/8 "2020-06-17T12:33:45Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mayro](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mayro/32/12816_2.png) [@mayro](https://discourse.codecombat.com/u/mayro)
#### Post date: [June 17, 2020, 3:02pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/10 "2020-06-17T15:02:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mayro](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mayro/32/12816_2.png) [@mayro](https://discourse.codecombat.com/u/mayro)
#### Post date: [June 17, 2020, 3:05pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/11 "2020-06-17T15:05:46Z")

</div>

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

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [June 17, 2020, 3:06pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/12 "2020-06-17T15:06:52Z")

</div>

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=2_2_2=8. Do you understand now?

---

<div class="post-metadata">

### Author: ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)
#### Post date: [June 17, 2020, 6:04pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/13 "2020-06-17T18:04:32Z")

</div>

have ou finished the level?

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [June 17, 2020, 6:11pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/14 "2020-06-17T18:11:16Z")

</div>

I think so… So have you finished the level, @mayro?

---

<div class="post-metadata">

### Author: ![mayro](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mayro/32/12816_2.png) [@mayro](https://discourse.codecombat.com/u/mayro)
#### Post date: [June 17, 2020, 6:30pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/15 "2020-06-17T18:30:41Z")

</div>

yes (20 characterssss)

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [June 17, 2020, 6:31pm UTC](https://discourse.codecombat.com/t/solved-cubic-minefield-javascript/22283/16 "2020-06-17T18:31:17Z")

</div>

Congratulations then! 🥳
