Is it possible to round numbers to a given number of decimal places in JavaScript? Math:Round() seems to only round to whole numbers. Maybe something similar to a classical 'trim' method would do the trick, but I can't find anything that would do the job....??
// round to the nearest tenth
function roundToTenth(numb) {
var ten_x_numb = numb * 10;
var round_numb = Math.round(ten_x_numb) / 10;
return round_numb;
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.