How to Convert A Positive Number Into A Negative Number in Javascript

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…

The post How to Convert A Positive Number Into A Negative Number in Javascript appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored 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.

The post How to Convert A Positive Number Into A Negative Number in Javascript appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Ariessa Norramli


Print Share Comment Cite Upload Translate Updates
APA

Ariessa Norramli | Sciencx (2021-02-17T07:32:26+00:00) How to Convert A Positive Number Into A Negative Number in Javascript. Retrieved from https://www.scien.cx/2021/02/17/how-to-convert-a-positive-number-into-a-negative-number-in-javascript/

MLA
" » How to Convert A Positive Number Into A Negative Number in Javascript." Ariessa Norramli | Sciencx - Wednesday February 17, 2021, https://www.scien.cx/2021/02/17/how-to-convert-a-positive-number-into-a-negative-number-in-javascript/
HARVARD
Ariessa Norramli | Sciencx Wednesday February 17, 2021 » How to Convert A Positive Number Into A Negative Number in Javascript., viewed ,<https://www.scien.cx/2021/02/17/how-to-convert-a-positive-number-into-a-negative-number-in-javascript/>
VANCOUVER
Ariessa Norramli | Sciencx - » How to Convert A Positive Number Into A Negative Number in Javascript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/17/how-to-convert-a-positive-number-into-a-negative-number-in-javascript/
CHICAGO
" » How to Convert A Positive Number Into A Negative Number in Javascript." Ariessa Norramli | Sciencx - Accessed . https://www.scien.cx/2021/02/17/how-to-convert-a-positive-number-into-a-negative-number-in-javascript/
IEEE
" » How to Convert A Positive Number Into A Negative Number in Javascript." Ariessa Norramli | Sciencx [Online]. Available: https://www.scien.cx/2021/02/17/how-to-convert-a-positive-number-into-a-negative-number-in-javascript/. [Accessed: ]
rf:citation
» How to Convert A Positive Number Into A Negative Number in Javascript | Ariessa Norramli | Sciencx | https://www.scien.cx/2021/02/17/how-to-convert-a-positive-number-into-a-negative-number-in-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.