JavaScript Program to find the absolute value of a number

In this program, you will learn how to find the absolute value of a number in JavaScript.


let z = Math.abs(num)

JavaScript Program to find the absolute value of a number

Example: How to find the absolute value of a number in JavaScript

let num = prompt("Enter a number")

let z = Math.abs(num)
console.log("Absolute value is:" +z)

Output:

Enter a number> -453
Absolute value is:453