javascript round up number code example
Example 1: js rounding
Math.floor(5.5)
Math.round(5.5)
Math.ceil(5.5)
Math.floor(5.57 * 10) / 10
Example 2: javascript ceiling
var ceiling1 = Math.ceil(4.7);
var ceiling2 = Math.ceil(-3.4);
Example 3: rounding off numbers javascript
Math.round(3.14159 * 100) / 100
3.14159.toFixed(2);
parseFloat(3.14159.toFixed(2));
Example 4: round down the number javascript
+3.5 => +3.0
-3.5 => -4.0
+3.5 => +3.0 using Math.floor()
-3.5 => -3.0 using Math.ceil()
Example 5: run down number javascript
using Math.floor
console.log(Math.floor(5.95));
console.log(Math.floor(5.05));
console.log(Math.floor(5));
console.log(Math.floor(-5.05));