开发者

How to change a negative number to positive?

开发者 https://www.devze.com 2022-12-12 00:30 出处:网络
How to make a negative number to be positive (ie. -25 to be 25) in JavaScri开发者_开发问答pt?There are various ways:

How to make a negative number to be positive (ie. -25 to be 25) in JavaScri开发者_开发问答pt?


There are various ways:

var m, n = -25;
m = -1 * n;
m = -n;
m = Math.abs(n);


var n= -25;
var m= -1 * n;


use Math.abs function

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号