<!DOCTYPE html>
<html>
<body>
<h3 style="color:Blue">JavaScript floor() Method Example</h3>
<p id="demo">Click the button to round the number 1.6 downward to it's nearest integer.</p>
<button onclick="myFunction()">Click on</button>
<script type="text/javascript">
function myFunction() {
var a = Math.floor(0.60);
document.write("1st Value of exp : " + a);
var b = Math.floor(0.40);
document.write("<br />2nd Value of exp : " + b);
var c = Math.floor(5);
document.write("<br />3th Value of exp : " + c);
var d = Math.floor(5.1);
document.write("<br />4th Value of exp : " + d);
var e = Math.floor(-5.1);
document.write("<br />5th Value of exp : " + e);
var f = Math.floor(-5.9);
document.write("<br />6th Value of exp : " + f);
var x = document.getElementById("demo");
x.innerHTML = a + "<br>" + b + "<br>" + c + "<br>" + d + "<br>" + e + "<br>" + f;
}
</script>
</body>
</html>
|