JS负数转正数函数:Math.abs(x)。示例如下:

let x = -5;
console.log(Math.abs(x));