js round up decimal
var avg=10.55;
console.log(Math.round(avg)); //Prints 11function round(value, precision) {
var multiplier = Math.pow(10, precision || 0);
return Math.round(value * multiplier) / multiplier;
}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
Math.round(3.14159) // 3
Math.round(3.5) // 4
Math.floor(3.8) // 3
Math.ceil(3.2) // 4
round(12345.6789, -1) // 12350
round(12345.6789, -2) // 12300
Also in JavaScript:
- string literals javascript
- tutorial of machine learning js
- javascript validate date
- js tab in textarea
- mongoose
- event handler attachment jquery
- jquery example sheetjs
- javascript get last url segment
- sars
- js check if div have another div
- insert element to dom
- add variable inside regex in javascript
- exit popup javascript
- Math.random() javascript
- merge two strings with alternate characters javascript
- javascript loadImage
- vector
- js insertbefore
- get element by tag name
- how can we take selected index value of dropdown in javascript
- get ckeditor textarea value in jquery
- how to change size of image js
- how to remove last element in js
- javascript get all select options