# Convert a negative number to positive in JavaScript

• Last Updated : 29 May, 2019

We can convert a negative number to a positive number in javascript by the methods described below.

Method 1: This is a general method in which we will first check whether the number is already positive or negative, if the number is negative then we will multiply the number with -1 to make it positive.

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

Syntax:

```if (a < 0) {
a = a * -1;
}
```

Example: Below is the implementation of the above approach:

 ``

Output:

```10
5
```

Method 2: In this method we will use Math.abs() function to convert negative number to positive number.

Syntax:

`Math.abs(value)`

Example: Below is the implementation of the above approach:

 `                                    `

Output:

```30
15
```

My Personal Notes arrow_drop_up