How to Convert A Positive Number Into A Negative Number in Javascript
Posted on: February 17, 2021 by Ariessa Norramli
In this article, you will learn how to convert a positive number into a negative number in Javascript.
Let’s say you have a number variable called ‘a’ with value 123.
var a = 123;
In order to convert a positive number into a negative number, you can use the unary negation operator -
.
var a = 123;
console.log(-a);
Note: The unary negation operator -
functions by converting any value on its right side into a number and negates it.
Share on social media
//