title: Using a JavaScript calculator to calculate the Math.power function
body: <p>I am designing my own JavaScript calculator with HTML values that look like this:</p>
  
  <pre><code>        &lt;input type="button" class="button gray" 
          value="tan" onclick='tan()'&gt;
  
          &lt;input type="button" class="button black" value="3" 
          onclick='v("3")'&gt;
  </code></pre>
  
  <p>And the JavaScript code looks something like this:</p>
  
  <pre><code>    function tan() {
        var getValue = document.getElementById("d").value;
        document.getElementById("d").value=Math.tan(getValue);
       }
  
       function v(val) {
           document.getElementById("d").value+=val;
        }
  </code></pre>
  
  <p>Where the ID "d" represents the screen in which the values from the buttons one presses are entered.</p>
  
  <p>Where I'm having trouble is having a button utilize the Math.pow(a,b) function. Once you press the button with the value x^y I want these steps to be taken:</p>
  
  <ol>
  <li>Take the value from element "d"</li>
  <li>Take the value from the next button pressed and enter that as the second value in the Math.pow() function.</li>
  </ol>
  
  <p>I've got step one down, I just haven't figured out step two. The JavaScript code I envision is something like this:    </p>
  
  <pre><code>   function power() {
     var getValue = document.getElementById("d").value;
         ......   
         ......
         var powerTotal = Math.pow(getValue,nextValue);
         document.getElementById("d").value = powerTotal;
        }
  </code></pre>
  
  <p>(getValue is the initial value, nextValue is the value of the next button pressed after the power button is pressed)</p>
  
  <p>Thank you for your help in advance!!!</p>