Prev Demo
Returning Absolute Values Of Different Numbers
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Absolute values of different numbers</h1> <p>Click the below button to return the absolute value of different numbers.</p> <input type="button" onclick="myFunction()" value="Click"> <p id="myId"></p> <script> function myFunction() { var a = Math.abs(3.5); var b = Math.abs(-3.5); var c = Math.abs("TechFunda"); var d = Math.abs(null); var e = Math.abs(a + b); var f = Math.abs(a * b); var r = a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e + "<br>" + f; document.getElementById("myId").innerHTML = r; } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output