# How to Round to Nearest Hundredth JavaScript

Round to Nearest Hundredth Javascript | Rounding numbers simplifies and facilitates their use. The numbers are still rather near to what they were original, despite being slightly less exact.

Users round numbers in a variety of settings, including several situations that you’ll encounter on a routine basis. In this article, we will see how to round to the nearest hundredth in JavaScript using two different methods. But first, let’s have a look at some examples that will give you a better insight.

Example 1:
Number = 123
The number after rounding to the nearest hundredth = 200

Example 2:
Number = 882.23
The number after rounding to the nearest hundredth = 900

## Round To Nearest Hundredth JavaScript using Math.round()

Execute the Math.round() function, pass the integer divided by 100, and multiply the result by 100, e.g. Math.round(num /100)*100. The Math.round() function takes a value and rounds it to the nearest integer. A number is rounded to the nearest integer with this function. Approach:-

1. Round to the nearest hundredth by multiplying it by 100.
2. To round to the nearest hundredth, multiply the result by 100.

``````function roundNearest100(num) {
return Math.round(num / 100) * 100;
}
console.log(roundNearest100(199));
console.log(roundNearest100(840));``````

Output:-

200
800

Let us another program to demonstrate how to round to the nearest hundredth JavaScript without any input

``````function roundNearest100(num) {
return Math.round(num / 100) * 100;
}
console.log(roundNearest100()); ``````

Output:-

NaN

## Round to the Nearest Hundredth JavaScript Using Math.ceil()

``````const num = 732;
const roundOffTo = (num, factor = 1) => {
const res = Math.ceil(num / 100) * 100
return res;
};
console.log(roundOffTo(num, 100));``````

Output:-

800

Another Example to demonstrate how to round to the nearest hundredth in JavaScript.

``````const num = 0;
const roundOffTo = (num, factor = 1) => {
const res = Math.ceil(num / 100) * 100
return res;
};
console.log(roundOffTo(num, 100));``````

Output:-

0

Adding no value to the program above will produce no results. This brings us to the end of this article. We learned how to round to the nearest hundredth in JavaScript using different methods. We can also use the Math.ceil() function or the Math.pow() function instead of Math.round(). Also see:- JavaScript Round to 2 Decimal Places

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!