codegurukool.com · Free coding tutorials & online compiler

Home › JavaScript Tutorial › JS math

JS math

The Math object.

Math.round, floor, ceil, max, min, sqrt, pow, PI and random.

Example code

<pre id='o'></pre>
<script>
o.textContent=[Math.round(4.6),Math.floor(4.9),Math.max(3,8,1),Math.sqrt(81),Math.PI.toFixed(3),1+Math.floor(Math.random()*6)+' (dice)'].join('\n');
</script>

Run this code in the online editor

← JS iterationsJS RegExp →