# Javascript program to find square of a number Looking for a way to find the square of a number in Javascript then you are at the right place today I will show you how to create a Javascript program to find square root of a number I will show you all the ways of doing this so follow up with me till the end.

So what is a square of a number. In mathematics, a square of a number is the product of a number multiplied by itself. For example square root of 3 is 9 becuase 3 multiplied by itself which is 3 is 9 another example square of 2 is 4 because 2 x 2 = 4.

Now you know what is a square of a number now lets create a Javascript program which will find the square of a number.

## 3 ways to find square of a number in Javascript

I will show you 3 ways of finding the square of a number in Javascript all this ways are very simple and easy you can use any of the way you like I will provide all the code you need for this Javascript program below are ways that you can use to find square.

• Use the `Math.pow()` Method to Find Square a Number in JavaScript.
• Use the `Exponentiation` Method to Find Square a Number in JavaScript.
• Finding Square of a Number by multiplying by itself in Javascript.

Now let’s see how to do this in action if you want to more javascript guides like this you can check our javascript section here – Javascript guides.

### 1. Finding square of number using Math.pow()

We will find the square of a number using the builtin javascript function which is provided in the Math module which `Math.pow()` method. This function takes two arguments first one is the number or a value which should be multiplied.

The second argument is number of times we want that number to be multiplied so in our case we want to find the square so it will be 2 so now let’s see this is in code.

```				```
let num = 4;
let squareNum = Math.pow(num,2);
console.log(squareNum);

```
```
```				```
// OUTPUT
16
```
```

### 2. Finding square of number using Exponentiation

This is another method which we can use to find the square of a number this one is very simple and easy to do we will use exponentiation which looks like this 4 ** 2  this works just like the math.pow() the first number is the number we want to square of.

The second number is how many time it should multiplied by it self which would be 2 times so let’s see how to do this in code.

```				```
let num = 4;
let squareNum = num ** 2
console.log(squareNum);

```
```
```				```
// OUTPUT
16
```
```

### 3. Finding square of a number by multiplying by itself

The last way of finding the square of a number in Javascript is just by multiplying the number by itself don’t worry if you don’t understand this you can see the below code

```				```
let num = 4;
let squareNum = num * num
console.log(squareNum);

```
```
```				```
// OUTPUT
16
```
```

This is one of the simplest method you can use to find the square of a number in Javascript I hope you found this tutorial guide helpful and useful below are more guides which you can read:

So this was for today if you want more guides like this and want to stay updated on our latest guides you can join our Telegram channel here – Join Coderzway Telegram Channel

Thank you for reading, Have a nice day 🙂