Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Get the Absolute Value of a Number</title> </head> <body> <script> document.write(Math.abs(-1) + "<br>"); // Prints: 1 document.write(Math.abs(1) + "<br>"); // Prints: 1 document.write(Math.abs(-5) + "<br>"); // Prints: 5 document.write(Math.abs(-10.5)); // Prints: 10.5 </script> </body> </html>