Math.floor(number)
Let us try with some examples.
document.write (Math.floor(11.257)); // output 11
document.write ("<br>----<br>");
document.write (Math.floor(1.56)); // output 1
document.write ("<br>----<br>");
document.write (Math.floor(-3.564)); // output -4
document.write ("<br>----<br>");
document.write (Math.floor(-7.164)); // output -8
document.write ("<br>----<br>");
document.write(Math.floor()); // Output NaN
document.write("<br>");
document.write(Math.floor('abc')); // Output NaN
document.write("<br>");
<script>
document.write(Math.round(5.42)+'<br>'); // Output 5
document.write(Math.floor(5.42)+'<br>'); // Output 5
document.write(Math.round(5.67)+'<br>'); // Output 6
document.write(Math.floor(5.67)+'<br>'); // Output 5
document.write(Math.round(-5.42)+'<br>'); // Output -5
document.write(Math.floor(-5.42)+'<br>'); // Output -6
document.write(Math.round(-5.67)+'<br>'); // Output -6
document.write(Math.floor(-5.67)+'<br>'); // Output -6
</script>
Makwana Parvez | 11-02-2019 |
very good and explaination of example is very nice |