# JavaScript pow() method

Some times programmers may need to evaluate the value by the power of some numbers therefore JavaScript provides an in-built function Math.pow().

Tutorials

# JavaScript pow() method

Some times programmers may need to evaluate the value by the power of some numbers therefore JavaScript provides an in-built function Math.pow().

Syntax:

 Math.pow(x,y);

Math.pow(x,y) returns value of x to the power of y (xy). Where x and y both are required.

In the following example we will describe you the use of Math.pow() method with very simple code. Here in this example code we have created two input boxes into which we will take the values of x and y from the user side.

Description of code:

Take two values x and y from the user and then apply the Math object's method pow() onto it. When user clicks on the button "Show Value" it calls the method callPow() as defined in the JavaScript within our <script></script> tag.

 ``` function callPow(){ var val= document.getElementById("txt").value; var power= document.getElementById("txt2").value; alert(Math.pow(val,power)); } ```

Here we have taken the values of x and y into the "val" and "power" variables. Full html code for this example is as follows :

 ```
Pow Example
Input number : to the power
```

Output :

Input numbers into the text boxes :

then click on button "Show Value" to view results.

Calculate 3 to the power 5 (35).

# JavaScript pow() method

Related Tutorials

Discuss: JavaScript pow() method

Subject (*):

Binny
May 26, 2011
Nice

Really helped a lot.. thanks :)...keep it up for more things
Tony
January 3, 2012
POW

Hello, I am not good in programming. I have the input number only 2, and the POW number like 3 (or up to 13) but the POW number comes with A and B,and I know the Value is 8, but the thing I want it to list like: POW = 3 ( The line list will depend on the POW number): 1A, 2A, 3A; 1A, 2A, 3B; 1A, 2B, 3A; 1A, 2B, 3B; etc.... Your help will be very grateful Regards,