round up decimal number in javascript code example
Example 1: javascript round decimal 2 digits
var numb = 123.23454;
numb = numb.toFixed(2);
Example 2: rounding off numbers javascript
Math.round(3.14159 * 100) / 100 // 3.14
3.14159.toFixed(2); // 3.14 returns a string
parseFloat(3.14159.toFixed(2)); // 3.14 returns a number
Example 3: round to nearest decimal javascript
round(12345.6789, 2) // 12345.68
round(12345.6789, 1) // 12345.7